mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:32:29 +08:00
vfs: shorten the locking window for vfs/refresh
Before this change we locked the root directory, recursively fetched the listing, applied it then unlocked the root directory. After this change we recursively fetch the listing then apply it with the root directory locked which shortens the time that the root directory is locked greatly. With the original method and the new method the subdirectories are left unlocked and so potentially could be changed leading to inconsistencies. This change makes the potential for inconsistencies slightly worse by leaving the root directory unlocked at a gain of a much more responsive system while runing vfs/refresh. See: https://forum.rclone.org/t/rclone-rc-vfs-refresh-locking-directory-being-refreshed/9004
This commit is contained in:
parent
d233efbf63
commit
1692c6bd0a
11
vfs/dir.go
11
vfs/dir.go
|
@ -290,14 +290,17 @@ func (d *Dir) _readDirFromEntries(entries fs.DirEntries, dirTree walk.DirTree, w
|
|||
// readDirTree forces a refresh of the complete directory tree
|
||||
func (d *Dir) readDirTree() error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
f, path := d.f, d.path
|
||||
d.mu.Unlock()
|
||||
when := time.Now()
|
||||
d.read = time.Time{}
|
||||
fs.Debugf(d.path, "Reading directory tree")
|
||||
dt, err := walk.NewDirTree(d.f, d.path, false, -1)
|
||||
fs.Debugf(path, "Reading directory tree")
|
||||
dt, err := walk.NewDirTree(f, path, false, -1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.read = time.Time{}
|
||||
err = d._readDirFromDirTree(dt, when)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue
Block a user