Improve error reporting when moving a transcoded file fails (#4101)

This commit is contained in:
its-josh4 2023-09-10 19:48:39 -07:00 committed by GitHub
parent 06d76307c3
commit 798db1a8ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

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

View file

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