3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00

Defer closing of files ()

Signed-off-by: CodeLingo Bot <bot@codelingo.io>
This commit is contained in:
CodeLingo Bot 2019-05-22 18:48:47 +12:00 committed by Carl Bergquist
parent 9cdf0f4f9c
commit 3ff3e0f2ac
4 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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 {