mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 12:55:18 +00:00
Merge pull request #3308 from MichaelEischer/fix-not-a-directory
local: Ignore files in intermediate folders
This commit is contained in:
commit
4baebdc6f5
8
changelog/unreleased/issue-3302
Normal file
8
changelog/unreleased/issue-3302
Normal file
@ -0,0 +1,8 @@
|
||||
Bugfix: Fix `fdopendir: not a directory` error for local backend
|
||||
|
||||
The `check`, `list packs`, `prune` and `rebuild-index` commands failed
|
||||
for the local backend when the `data` folder in the repository contained
|
||||
files. This has been fixed.
|
||||
|
||||
https://github.com/restic/restic/issues/3302
|
||||
https://github.com/restic/restic/pull/3308
|
@ -245,7 +245,7 @@ func (b *Local) List(ctx context.Context, t restic.FileType, fn func(restic.File
|
||||
if subdirs {
|
||||
err = visitDirs(ctx, basedir, fn)
|
||||
} else {
|
||||
err = visitFiles(ctx, basedir, fn)
|
||||
err = visitFiles(ctx, basedir, fn, false)
|
||||
}
|
||||
|
||||
if b.IsNotExist(err) {
|
||||
@ -279,7 +279,7 @@ func visitDirs(ctx context.Context, dir string, fn func(restic.FileInfo) error)
|
||||
}
|
||||
|
||||
for _, f := range sub {
|
||||
err = visitFiles(ctx, filepath.Join(dir, f), fn)
|
||||
err = visitFiles(ctx, filepath.Join(dir, f), fn, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -287,12 +287,19 @@ func visitDirs(ctx context.Context, dir string, fn func(restic.FileInfo) error)
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func visitFiles(ctx context.Context, dir string, fn func(restic.FileInfo) error) error {
|
||||
func visitFiles(ctx context.Context, dir string, fn func(restic.FileInfo) error, ignoreNotADirectory bool) error {
|
||||
d, err := fs.Open(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ignoreNotADirectory {
|
||||
fi, err := d.Stat()
|
||||
if err != nil || !fi.IsDir() {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
sub, err := d.Readdir(-1)
|
||||
if err != nil {
|
||||
// ignore subsequent errors
|
||||
|
Loading…
Reference in New Issue
Block a user