From 07d85297c0f6eef42ba7bf1a5ab2a767b8c2cee0 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 7 Jul 2023 16:06:31 +0100 Subject: [PATCH] local: fix partial directory read for corrupted filesystem Before this change if a directory entry could be listed but not lstat-ed then rclone would give an error and abort the directory listing with the error failed to read directory entry: failed to read directory "XXX": lstat XXX This change makes sure that the directory listing carries on even after this kind of error. The sync will be failed but it will carry on. This problem was caused by a programming error setting the err variable in an outer scope when it should have been using a local err variable. See: https://forum.rclone.org/t/sync-aborts-if-even-one-single-unreadable-folder-is-encountered/39653 --- backend/local/local.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/local/local.go b/backend/local/local.go index a83a3c455..bb9f739eb 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -516,7 +516,7 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e continue } } - err = fmt.Errorf("failed to read directory %q: %w", namepath, fierr) + fierr = fmt.Errorf("failed to get info about directory entry %q: %w", namepath, fierr) fs.Errorf(dir, "%v", fierr) _ = accounting.Stats(ctx).Error(fserrors.NoRetryError(fierr)) // fail the sync continue