several one-line panic, race, and logic fixes (#7766)
Этот коммит содержится в:
@@ -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{}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Ссылка в новой задаче
Block a user