mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Defer closing of files (#17213)
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
This commit is contained in:
parent
9cdf0f4f9c
commit
3ff3e0f2ac
pkg
@ -316,6 +316,7 @@ func GetHomeDashboard(c *m.ReqContext) Response {
|
||||
if err != nil {
|
||||
return Error(500, "Failed to load home dashboard", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
dash := dtos.DashboardFullWithMeta{}
|
||||
dash.Meta.IsHome = true
|
||||
|
@ -46,10 +46,11 @@ func (az *AzureBlobUploader) Upload(ctx context.Context, imageDiskPath string) (
|
||||
blob := NewStorageClient(az.account_name, az.account_key)
|
||||
|
||||
file, err := os.Open(imageDiskPath)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
randomFileName := util.GetRandomString(30) + ".png"
|
||||
// upload image
|
||||
az.log.Debug("Uploading image to azure_blob", "container_name", az.container_name, "blob_name", randomFileName)
|
||||
|
@ -67,6 +67,7 @@ func (u *GCSUploader) uploadFile(client *http.Client, imageDiskPath, key string)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fileReader.Close()
|
||||
|
||||
reqUrl := fmt.Sprintf(uploadUrl, u.bucket, key)
|
||||
u.log.Debug("Request URL: ", reqUrl)
|
||||
|
@ -69,6 +69,7 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
sess, err = session.NewSession(cfg)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user