forked from TrueCloudLab/restic
Merge pull request #3623 from invine/issue-3464
Skip lock file creation on forget with --no-lock and --dry-run
This commit is contained in:
commit
df89aa0087
2 changed files with 20 additions and 4 deletions
9
changelog/unreleased/issue-3464
Normal file
9
changelog/unreleased/issue-3464
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Enhancement: Skip lock creation on forget if --no-lock and --dry-run
|
||||||
|
|
||||||
|
Restic used to silently ignore --no-lock option of forget. It now skips
|
||||||
|
creation of lock file in case of both --dry-run and --no-lock are specified. If
|
||||||
|
--no-lock option is specified without --dry-run then restic prints a warning
|
||||||
|
message to stderr.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/issues/3464
|
||||||
|
https://github.com/restic/restic/pull/3623
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/restic/restic/internal/errors"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -108,10 +109,16 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
lock, err := lockRepoExclusive(gopts.ctx, repo)
|
if gopts.NoLock && !opts.DryRun {
|
||||||
defer unlockRepo(lock)
|
return errors.Fatal("--no-lock is only applicable in combination with --dry-run for forget command")
|
||||||
if err != nil {
|
}
|
||||||
return err
|
|
||||||
|
if !opts.DryRun || !gopts.NoLock {
|
||||||
|
lock, err := lockRepoExclusive(gopts.ctx, repo)
|
||||||
|
defer unlockRepo(lock)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(gopts.ctx)
|
ctx, cancel := context.WithCancel(gopts.ctx)
|
||||||
|
|
Loading…
Reference in a new issue