mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CLI: Return error and aborts when plugin file extraction fails (#20849)
Return error and aborts when plugin file extraction fails. If file is in use, a somewhat user-friendly message is returned. Fixes #20841
This commit is contained in:
parent
02bbdca604
commit
79c0fa4ca5
@ -241,11 +241,9 @@ func extractFiles(archiveFile string, pluginName string, filePath string, allowS
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
|
||||
err = extractFile(zf, newFile)
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to extract file: %v \n", err)
|
||||
continue
|
||||
return errutil.Wrap("Failed to extract file", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -288,6 +286,12 @@ func extractFile(file *zip.File, filePath string) (err error) {
|
||||
if os.IsPermission(err) {
|
||||
return xerrors.Errorf(permissionsDeniedMessage, filePath)
|
||||
}
|
||||
|
||||
unwrappedError := xerrors.Unwrap(err)
|
||||
if unwrappedError != nil && strings.EqualFold(unwrappedError.Error(), "text file busy") {
|
||||
return fmt.Errorf("file %s is in use. Please stop Grafana, install the plugin and restart Grafana", filePath)
|
||||
}
|
||||
|
||||
return errutil.Wrap("Failed to open file", err)
|
||||
}
|
||||
defer func() {
|
||||
|
Loading…
Reference in New Issue
Block a user