From a8535aba58c3fe5056d35e5fd14d0400e757ca38 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Fri, 4 Apr 2025 10:22:54 -0400 Subject: [PATCH] backend/local: ignore chmod "not supported" errors --- changelog/unreleased/issue-5342 | 7 +++++++ internal/backend/local/local_unix.go | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/issue-5342 diff --git a/changelog/unreleased/issue-5342 b/changelog/unreleased/issue-5342 new file mode 100644 index 000000000..e9887fda2 --- /dev/null +++ b/changelog/unreleased/issue-5342 @@ -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 diff --git a/internal/backend/local/local_unix.go b/internal/backend/local/local_unix.go index e52587456..b885ae1a3 100644 --- a/internal/backend/local/local_unix.go +++ b/internal/backend/local/local_unix.go @@ -43,5 +43,12 @@ func isMacENOTTY(err error) bool { // set file to readonly 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 }