Merge pull request #5345 from mikix/chmod-enotsup

backend/local: ignore chmod "not supported" errors
This commit is contained in:
Michael Eischer 2025-07-21 22:28:53 +02:00 committed by GitHub
commit b71fe91643
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,7 @@
Bugfix: Ignore "chmod not supported" errors when writing files
Restic 0.18.0 introduced a bug that caused "chmod xxx: operation not supported"
errors to appear when writing to a local file repository that did not support
chmod (like CIFS or WebDAV mounted via FUSE). Restic now ignores those errors.
https://github.com/restic/restic/issues/5342

View File

@ -43,5 +43,12 @@ func isMacENOTTY(err error) bool {
// set file to readonly // set file to readonly
func setFileReadonly(f string, mode os.FileMode) error { func setFileReadonly(f string, mode os.FileMode) error {
return os.Chmod(f, mode&^0222) err := os.Chmod(f, mode&^0222)
// ignore the error if the FS does not support setting this mode (e.g. CIFS with gvfs on Linux)
if err != nil && errors.Is(err, errors.ErrUnsupported) {
return nil
}
return err
} }