[MM-28923] Fix errcheck issues in server/channels/app/file.go (#30878)
Co-authored-by: Claude <noreply@anthropic.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e10a1309c1
Коммит
dc2827a63e
@@ -90,7 +90,6 @@ issues:
|
||||
channels/api4/websocket_test.go|\
|
||||
channels/app/bot_test.go|\
|
||||
channels/app/brand.go|\
|
||||
channels/app/file.go|\
|
||||
channels/app/file_test.go|\
|
||||
channels/app/helper_test.go|\
|
||||
channels/app/permissions_test.go|\
|
||||
|
||||
@@ -1165,7 +1165,9 @@ func prepareImage(rctx request.CTX, imgDecoder *imaging.Decoder, imgData io.Read
|
||||
if err != nil {
|
||||
return nil, "", nil, fmt.Errorf("prepareImage: failed to decode image: %w", err)
|
||||
}
|
||||
imgData.Seek(0, io.SeekStart)
|
||||
if _, err = imgData.Seek(0, io.SeekStart); err != nil {
|
||||
return nil, "", nil, fmt.Errorf("prepareImage: failed to seek image data: %w", err)
|
||||
}
|
||||
|
||||
// Flip the image to be upright
|
||||
orientation, err := imaging.GetImageOrientation(imgData, imgType)
|
||||
@@ -1409,7 +1411,7 @@ func (a *App) CreateZipFileAndAddFiles(fileBackend filestore.FileBackend, fileDa
|
||||
// Create Zip File (temporarily stored on disk)
|
||||
conglomerateZipFile, err := os.Create(zipFileName)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("failed to create temporary zip file %q: %w", zipFileName, err)
|
||||
}
|
||||
defer os.Remove(zipFileName)
|
||||
|
||||
@@ -1422,10 +1424,13 @@ func (a *App) CreateZipFileAndAddFiles(fileBackend filestore.FileBackend, fileDa
|
||||
return err
|
||||
}
|
||||
|
||||
conglomerateZipFile.Seek(0, 0)
|
||||
_, err = conglomerateZipFile.Seek(0, 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to seek to beginning of zip file %q: %w", conglomerateZipFile.Name(), err)
|
||||
}
|
||||
_, err = fileBackend.WriteFile(conglomerateZipFile, path.Join(directory, zipFileName))
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("failed to write zip file to file backend at path %s: %w", path.Join(directory, zipFileName), err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -308,7 +308,7 @@ func TestCreateZipFileAndAddFiles(t *testing.T) {
|
||||
err := th.App.CreateZipFileAndAddFiles(&mockBackend, []model.FileData{}, zipName, directory)
|
||||
|
||||
require.Error(t, err)
|
||||
require.Equal(t, err.Error(), "only those who dare to fail greatly can ever achieve greatly")
|
||||
require.Equal(t, err.Error(), "failed to write zip file to file backend at path directory-to-heaven/zip-file-name-to-heaven.zip: only those who dare to fail greatly can ever achieve greatly")
|
||||
})
|
||||
|
||||
t.Run("write no file", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user