forked from TrueCloudLab/restic
cmd/restic: Use a dedicated cache for each rejectIfPresent
This commit is contained in:
parent
901cd5edef
commit
1ea518d5ef
3 changed files with 5 additions and 6 deletions
|
@ -372,9 +372,8 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, args []string) error {
|
||||||
opts.ExcludeIfPresent = append(opts.ExcludeIfPresent, "CACHEDIR.TAG:Signature: 8a477f597d28d172789f06886806bc55")
|
opts.ExcludeIfPresent = append(opts.ExcludeIfPresent, "CACHEDIR.TAG:Signature: 8a477f597d28d172789f06886806bc55")
|
||||||
}
|
}
|
||||||
|
|
||||||
rc := &rejectionCache{}
|
|
||||||
for _, spec := range opts.ExcludeIfPresent {
|
for _, spec := range opts.ExcludeIfPresent {
|
||||||
f, err := rejectIfPresent(spec, rc)
|
f, err := rejectIfPresent(spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ func rejectByPattern(patterns []string) RejectFunc {
|
||||||
// non-nil if the filename component of excludeFileSpec is empty. If rc is
|
// non-nil if the filename component of excludeFileSpec is empty. If rc is
|
||||||
// non-nil, it is going to be used in the RejectFunc to expedite the evaluation
|
// non-nil, it is going to be used in the RejectFunc to expedite the evaluation
|
||||||
// of a directory based on previous visits.
|
// of a directory based on previous visits.
|
||||||
func rejectIfPresent(excludeFileSpec string, rc *rejectionCache) (RejectFunc, error) {
|
func rejectIfPresent(excludeFileSpec string) (RejectFunc, error) {
|
||||||
if excludeFileSpec == "" {
|
if excludeFileSpec == "" {
|
||||||
return nil, errors.New("name for exclusion tagfile is empty")
|
return nil, errors.New("name for exclusion tagfile is empty")
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@ func rejectIfPresent(excludeFileSpec string, rc *rejectionCache) (RejectFunc, er
|
||||||
tf = excludeFileSpec
|
tf = excludeFileSpec
|
||||||
}
|
}
|
||||||
debug.Log("using %q as exclusion tagfile", tf)
|
debug.Log("using %q as exclusion tagfile", tf)
|
||||||
|
rc := &rejectionCache{}
|
||||||
fn := func(filename string, _ os.FileInfo) bool {
|
fn := func(filename string, _ os.FileInfo) bool {
|
||||||
return isExcludedByFile(filename, tf, tc, rc)
|
return isExcludedByFile(filename, tf, tc, rc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,8 @@ func TestMultipleIsExcludedByFile(t *testing.T) {
|
||||||
errs = append(errs, ioutil.WriteFile(p, []byte(f.path), 0600))
|
errs = append(errs, ioutil.WriteFile(p, []byte(f.path), 0600))
|
||||||
}
|
}
|
||||||
test.OKs(t, errs)
|
test.OKs(t, errs)
|
||||||
rc := &rejectionCache{}
|
fooExclude, _ := rejectIfPresent("NOFOO")
|
||||||
fooExclude, _ := rejectIfPresent("NOFOO", rc)
|
barExclude, _ := rejectIfPresent("NOBAR")
|
||||||
barExclude, _ := rejectIfPresent("NOBAR", rc)
|
|
||||||
m := make(map[string]bool)
|
m := make(map[string]bool)
|
||||||
walk := func(p string, fi os.FileInfo, err error) error {
|
walk := func(p string, fi os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue