backend: Only return top-level files for most dirs

Fixes #1478
This commit is contained in:
Alexander Neumann 2017-12-14 19:13:01 +01:00
parent 42a8c19aae
commit 7d8765a937
12 changed files with 49 additions and 15 deletions

View file

@ -252,15 +252,27 @@ func (b *Local) List(ctx context.Context, t restic.FileType) <-chan string {
go func() {
defer close(ch)
err := fs.Walk(b.Basedir(t), func(path string, fi os.FileInfo, err error) error {
basedir, subdirs := b.Basedir(t)
err := fs.Walk(basedir, func(path string, fi os.FileInfo, err error) error {
debug.Log("walk on %v, %v\n", path, fi.IsDir())
if err != nil {
return err
}
if path == basedir {
return nil
}
if !isFile(fi) {
return nil
}
if fi.IsDir() && !subdirs {
return filepath.SkipDir
}
debug.Log("send %v\n", filepath.Base(path))
select {
case ch <- filepath.Base(path):
case <-ctx.Done():