1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

march: fix deadlock when using --fast-list on syncs - fixes #8811

Before this change, it was possible to have a deadlock when using
--fast-list for a sync if both the source and destination supported
ListR.

This fixes the problem by shortening the locking window.
This commit is contained in:
Nick Craig-Wood
2025-09-11 17:27:15 +01:00
parent d2351e60b6
commit 45f45c987c

View File

@@ -137,20 +137,22 @@ func (m *March) makeListDir(ctx context.Context, f fs.Fs, includeAll bool, keyFn
)
return func(dir string, callback fs.ListRCallback) (err error) {
mu.Lock()
defer mu.Unlock()
if !started {
dirCtx := filter.SetUseFilter(m.Ctx, f.Features().FilterAware && !includeAll) // make filter-aware backends constrain List
dirs, dirsErr = walk.NewDirTree(dirCtx, f, m.Dir, includeAll, ci.MaxDepth)
started = true
}
if dirsErr != nil {
mu.Unlock()
return dirsErr
}
entries, ok := dirs[dir]
if !ok {
mu.Unlock()
return fs.ErrorDirNotFound
}
delete(dirs, dir)
mu.Unlock()
// We use a stable sort here just in case there are
// duplicates. Assuming the remote delivers the entries in a