Skip to content

Commit

Permalink
Improve error reporting when moving a transcoded file fails (stashapp…
Browse files Browse the repository at this point in the history
  • Loading branch information
its-josh4 authored Sep 11, 2023
1 parent 06d7630 commit 798db1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/fsutil/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func SafeMove(src, dst string) error {
err := os.Rename(src, dst)

if err != nil {
err = CopyFile(src, dst)
if err != nil {
return err
copyErr := CopyFile(src, dst)
if copyErr != nil {
return fmt.Errorf("copying file during SaveMove failed with: '%w'; renaming file failed previously with: '%v'", copyErr, err)
}

err = os.Remove(src)
Expand Down
2 changes: 1 addition & 1 deletion pkg/scene/generate/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (g Generator) generateFile(lockCtx *fsutil.LockContext, p Paths, pattern st
}

if err := fsutil.SafeMove(tmpFn, output); err != nil {
return fmt.Errorf("moving %s to %s", tmpFn, output)
return fmt.Errorf("moving %s to %s failed: %w", tmpFn, output, err)
}

return nil
Expand Down

0 comments on commit 798db1a

Please sign in to comment.