forked from TrueCloudLab/restic
33 lines
811 B
Go
33 lines
811 B
Go
package main
|
|
|
|
import (
|
|
"github.com/restic/restic/internal/archiver"
|
|
"github.com/restic/restic/internal/debug"
|
|
"github.com/restic/restic/internal/errors"
|
|
"github.com/restic/restic/internal/fs"
|
|
"github.com/restic/restic/internal/repository"
|
|
)
|
|
|
|
// rejectResticCache returns a RejectByNameFunc that rejects the restic cache
|
|
// directory (if set).
|
|
func rejectResticCache(repo *repository.Repository) (archiver.RejectByNameFunc, error) {
|
|
if repo.Cache == nil {
|
|
return func(string) bool {
|
|
return false
|
|
}, nil
|
|
}
|
|
cacheBase := repo.Cache.BaseDir()
|
|
|
|
if cacheBase == "" {
|
|
return nil, errors.New("cacheBase is empty string")
|
|
}
|
|
|
|
return func(item string) bool {
|
|
if fs.HasPathPrefix(cacheBase, item) {
|
|
debug.Log("rejecting restic cache directory %v", item)
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}, nil
|
|
}
|