Skip to content

Commit

Permalink
fail fast when iterating the directory tree for state metadata collec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
jxsl13 committed Jul 9, 2024
1 parent d26b68b commit c74c3ab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backupfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,15 +920,19 @@ func (fsys *BackupFS) lstat(name string) (fs.FileInfo, error) {
// in order to keep track of their state as well.
// /root -> /root/sub/ -> /root/sub/sub1
// iterate parent directories and keep track of their initial state.
IterateDirTree(filepath.Dir(name), func(subdirPath string) (bool, error) {
_, _ = IterateDirTree(filepath.Dir(name), func(subdirPath string) (bool, error) {
if fsys.alreadyFoundBaseInfo(subdirPath) {
return true, nil
}

// only in the case that we do not know the subdirectory already
// we do want to track the initial state of the sub directory.
// if it does not exist, it should not exist
_, _ = fsys.trackedLstat(subdirPath)
_, err = fsys.trackedLstat(subdirPath)
if err != nil {
// in case of an error we want to fail fast
return false, nil
}
return true, nil
})

Expand Down

0 comments on commit c74c3ab

Please sign in to comment.