2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-04 01:50:48 +00:00

check: Disable cache by default

This commit is contained in:
Alexander Neumann 2017-07-18 22:15:18 +02:00
parent 610b676444
commit 62ba9f1950

View File

@ -19,6 +19,9 @@ var cmdCheck = &cobra.Command{
Long: ` Long: `
The "check" command tests the repository for errors and reports any errors it The "check" command tests the repository for errors and reports any errors it
finds. It can also be used to read all data and therefore simulate a restore. finds. It can also be used to read all data and therefore simulate a restore.
By default, the "check" command will always load all data directly from the
repository and not use a local cache.
`, `,
DisableAutoGenTag: true, DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -30,6 +33,7 @@ finds. It can also be used to read all data and therefore simulate a restore.
type CheckOptions struct { type CheckOptions struct {
ReadData bool ReadData bool
CheckUnused bool CheckUnused bool
WithCache bool
} }
var checkOptions CheckOptions var checkOptions CheckOptions
@ -40,6 +44,7 @@ func init() {
f := cmdCheck.Flags() f := cmdCheck.Flags()
f.BoolVar(&checkOptions.ReadData, "read-data", false, "read all data blobs") f.BoolVar(&checkOptions.ReadData, "read-data", false, "read all data blobs")
f.BoolVar(&checkOptions.CheckUnused, "check-unused", false, "find unused blobs") f.BoolVar(&checkOptions.CheckUnused, "check-unused", false, "find unused blobs")
f.BoolVar(&checkOptions.WithCache, "with-cache", false, "use the cache")
} }
func newReadProgress(gopts GlobalOptions, todo restic.Stat) *restic.Progress { func newReadProgress(gopts GlobalOptions, todo restic.Stat) *restic.Progress {
@ -77,6 +82,11 @@ func runCheck(opts CheckOptions, gopts GlobalOptions, args []string) error {
return errors.Fatal("check has no arguments") return errors.Fatal("check has no arguments")
} }
if !opts.WithCache {
// do not use a cache for the checker
gopts.NoCache = true
}
repo, err := OpenRepository(gopts) repo, err := OpenRepository(gopts)
if err != nil { if err != nil {
return err return err