summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-11-03 10:25:38 -0500
committerCorey Hulen <corey@hulen.com>2017-11-03 08:25:38 -0700
commitd5dbdb273703a3add0f1c3287aa531854ab30269 (patch)
tree6b1fb9079f9fae9d25bdb7ea459261383ee720d6 /app
parent9d32cd42085bbb37460d815c6c1a00ad881c4895 (diff)
downloadchat-d5dbdb273703a3add0f1c3287aa531854ab30269.tar.gz
chat-d5dbdb273703a3add0f1c3287aa531854ab30269.tar.bz2
chat-d5dbdb273703a3add0f1c3287aa531854ab30269.zip
several one-line panic, race, and logic fixes (#7766)
Diffstat (limited to 'app')
-rw-r--r--app/auto_posts.go3
-rw-r--r--app/channel.go2
-rw-r--r--app/file.go2
-rw-r--r--app/saml.go2
-rw-r--r--app/user.go2
5 files changed, 7 insertions, 4 deletions
diff --git a/app/auto_posts.go b/app/auto_posts.go
index 254631c4e..6d1e352e5 100644
--- a/app/auto_posts.go
+++ b/app/auto_posts.go
@@ -44,6 +44,9 @@ func (cfg *AutoPostCreator) UploadTestFile() ([]string, bool) {
path, _ := utils.FindDir("web/static/images")
file, err := os.Open(path + "/" + filename)
+ if err != nil {
+ return nil, false
+ }
defer file.Close()
data := &bytes.Buffer{}
diff --git a/app/channel.go b/app/channel.go
index 4ccc12004..de60fbae3 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -1185,7 +1185,7 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotif
}
}
- times := map[string]int64{}
+ var times map[string]int64
if result := <-uchan; result.Err != nil {
return nil, result.Err
} else {
diff --git a/app/file.go b/app/file.go
index 11e503c40..3b221d9e2 100644
--- a/app/file.go
+++ b/app/file.go
@@ -259,10 +259,10 @@ func (a *App) UploadFiles(teamId string, channelId string, userId string, fileHe
for i, fileHeader := range fileHeaders {
file, fileErr := fileHeader.Open()
- defer file.Close()
if fileErr != nil {
return nil, model.NewAppError("UploadFiles", "api.file.upload_file.bad_parse.app_error", nil, fileErr.Error(), http.StatusBadRequest)
}
+ defer file.Close()
buf := bytes.NewBuffer(nil)
io.Copy(buf, file)
diff --git a/app/saml.go b/app/saml.go
index 3df00a9e1..bd9f647a1 100644
--- a/app/saml.go
+++ b/app/saml.go
@@ -36,10 +36,10 @@ func WriteSamlFile(fileData *multipart.FileHeader) *model.AppError {
}
file, err := fileData.Open()
- defer file.Close()
if err != nil {
return model.NewAppError("AddSamlCertificate", "api.admin.add_certificate.open.app_error", nil, err.Error(), http.StatusInternalServerError)
}
+ defer file.Close()
configDir, _ := utils.FindDir("config")
out, err := os.Create(configDir + filename)
diff --git a/app/user.go b/app/user.go
index 9f74ef303..999fabbf8 100644
--- a/app/user.go
+++ b/app/user.go
@@ -774,10 +774,10 @@ func (a *App) GetProfileImage(user *model.User) ([]byte, bool, *model.AppError)
func (a *App) SetProfileImage(userId string, imageData *multipart.FileHeader) *model.AppError {
file, err := imageData.Open()
- defer file.Close()
if err != nil {
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.open.app_error", nil, err.Error(), http.StatusBadRequest)
}
+ defer file.Close()
// Decode image config first to check dimensions before loading the whole thing into memory later on
config, _, err := image.DecodeConfig(file)