Merge pull request #3589 from metalsp0rk/copy-no-lock

Make Copy respect no lock
This commit is contained in:
MichaelEischer 2021-12-27 19:11:02 +01:00 committed by GitHub
commit 051cc7ce71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -0,0 +1,9 @@
Bugfix: Make copy command honor `--no-lock` for source repository
When passing the `--no-lock` flag to the copy command, restic still attempted
to lock the source repository, causing failures on read-only storage backends.
`--no-lock` is now respected and copy then no longer creates a lock in the
source repository.
https://github.com/restic/restic/issues/3518
https://github.com/restic/restic/pull/3589

View file

@ -73,11 +73,13 @@ func runCopy(opts CopyOptions, gopts GlobalOptions, args []string) error {
return err return err
} }
if !gopts.NoLock {
srcLock, err := lockRepo(ctx, srcRepo) srcLock, err := lockRepo(ctx, srcRepo)
defer unlockRepo(srcLock) defer unlockRepo(srcLock)
if err != nil { if err != nil {
return err return err
} }
}
dstLock, err := lockRepo(ctx, dstRepo) dstLock, err := lockRepo(ctx, dstRepo)
defer unlockRepo(dstLock) defer unlockRepo(dstLock)