2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00

Merge pull request #2982 from greatroar/archiver-error-handling

Check error in archiver before calling Select
This commit is contained in:
MichaelEischer 2020-10-05 19:19:47 +02:00 committed by GitHub
commit 1a490acd67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 13 deletions

View File

@ -234,10 +234,6 @@ func rejectByDevice(samples []string) (RejectFunc, error) {
debug.Log("allowed devices: %v\n", allowed) debug.Log("allowed devices: %v\n", allowed)
return func(item string, fi os.FileInfo) bool { return func(item string, fi os.FileInfo) bool {
if fi == nil {
return false
}
item = filepath.Clean(item) item = filepath.Clean(item)
id, err := fs.DeviceID(fi) id, err := fs.DeviceID(fi)
@ -301,10 +297,6 @@ func rejectBySize(maxSizeStr string) (RejectFunc, error) {
} }
return func(item string, fi os.FileInfo) bool { return func(item string, fi os.FileInfo) bool {
if fi == nil {
return false
}
// directory will be ignored // directory will be ignored
if fi.IsDir() { if fi.IsDir() {
return false return false

View File

@ -345,11 +345,6 @@ func (arch *Archiver) Save(ctx context.Context, snPath, target string, previous
// get file info and run remaining select functions that require file information // get file info and run remaining select functions that require file information
fi, err := arch.FS.Lstat(target) fi, err := arch.FS.Lstat(target)
if !arch.Select(abstarget, fi) {
debug.Log("%v is excluded", target)
return FutureNode{}, true, nil
}
if err != nil { if err != nil {
debug.Log("lstat() for %v returned error: %v", target, err) debug.Log("lstat() for %v returned error: %v", target, err)
err = arch.error(abstarget, fi, err) err = arch.error(abstarget, fi, err)
@ -358,6 +353,10 @@ func (arch *Archiver) Save(ctx context.Context, snPath, target string, previous
} }
return FutureNode{}, true, nil return FutureNode{}, true, nil
} }
if !arch.Select(abstarget, fi) {
debug.Log("%v is excluded", target)
return FutureNode{}, true, nil
}
switch { switch {
case fs.IsRegularFile(fi): case fs.IsRegularFile(fi):