From 40ee17167e36553b2773a6b2e65a5a2158099f56 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Tue, 6 Oct 2020 18:28:01 +0200 Subject: [PATCH] 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. --- internal/backend/local/local.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/backend/local/local.go b/internal/backend/local/local.go index 19f083a29..675c4a08d 100644 --- a/internal/backend/local/local.go +++ b/internal/backend/local/local.go @@ -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") }