local/sftp: Handling non-existing dirs in List()

This commit is contained in:
Alexander Neumann 2018-04-10 21:35:30 +02:00
parent 6a34e0d10f
commit 577faa7570
2 changed files with 12 additions and 1 deletions

View file

@ -235,7 +235,7 @@ func (b *Local) List(ctx context.Context, t restic.FileType, fn func(restic.File
debug.Log("List %v", t)
basedir, subdirs := b.Basedir(t)
return fs.Walk(basedir, func(path string, fi os.FileInfo, err error) error {
err := fs.Walk(basedir, func(path string, fi os.FileInfo, err error) error {
debug.Log("walk on %v\n", path)
if err != nil {
return err
@ -271,6 +271,13 @@ func (b *Local) List(ctx context.Context, t restic.FileType, fn func(restic.File
return ctx.Err()
})
if b.IsNotExist(err) {
debug.Log("ignoring non-existing directory")
return nil
}
return err
}
// Delete removes the repository and all files.

View file

@ -425,6 +425,10 @@ func (r *SFTP) List(ctx context.Context, t restic.FileType, fn func(restic.FileI
walker := r.c.Walk(basedir)
for walker.Step() {
if walker.Err() != nil {
if r.IsNotExist(walker.Err()) {
debug.Log("ignoring non-existing directory")
return nil
}
return walker.Err()
}