2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

local: Ignore permission errors on chmod call in Save/Remove operation

The file is already created with the proper permissions, thus the chmod
call is not critical. However, some file systems have don't allow
modifications of the file permissions. Similarly the chmod call in the Remove
operation should not prevent it from working.
This commit is contained in:
Michael Eischer 2020-10-06 18:28:01 +02:00
parent 0ae02f3030
commit 40ee17167e

View File

@ -130,7 +130,14 @@ func (b *Local) Save(ctx context.Context, h restic.Handle, rd restic.RewindReade
return errors.Wrap(err, "Close")
}
return setNewFileMode(filename, backend.Modes.File)
// ignore if the operation fails as some filesystems don't allow the chmod call
// e.g. exfat and network file systems with certain mount options
err = setNewFileMode(filename, backend.Modes.File)
if err != nil && !os.IsPermission(err) {
return errors.Wrap(err, "Chmod")
}
return nil
}
// Load runs fn with a reader that yields the contents of the file at h at the
@ -205,7 +212,7 @@ func (b *Local) Remove(ctx context.Context, h restic.Handle) error {
// reset read-only flag
err := fs.Chmod(fn, 0666)
if err != nil {
if err != nil && !os.IsPermission(err) {
return errors.Wrap(err, "Chmod")
}