Commit 79c0fa4c by Marcus Efraimsson Committed by GitHub

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
parent 02bbdca6
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment