mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 15:30:06 +08:00
vfs: fix race condition caused by unlocked reading of Dir.path
This commit is contained in:
parent
87d856d71b
commit
3c91abce74
|
@ -476,15 +476,16 @@ func (d *Dir) Stat(name string) (node Node, err error) {
|
||||||
func (d *Dir) ReadDirAll() (items Nodes, err error) {
|
func (d *Dir) ReadDirAll() (items Nodes, err error) {
|
||||||
// fs.Debugf(d.path, "Dir.ReadDirAll")
|
// fs.Debugf(d.path, "Dir.ReadDirAll")
|
||||||
d.mu.Lock()
|
d.mu.Lock()
|
||||||
defer d.mu.Unlock()
|
|
||||||
err = d._readDir()
|
err = d._readDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Debugf(d.path, "Dir.ReadDirAll error: %v", err)
|
fs.Debugf(d.path, "Dir.ReadDirAll error: %v", err)
|
||||||
|
d.mu.Unlock()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, item := range d.items {
|
for _, item := range d.items {
|
||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
|
d.mu.Unlock()
|
||||||
sort.Sort(items)
|
sort.Sort(items)
|
||||||
// fs.Debugf(d.path, "Dir.ReadDirAll OK with %d entries", len(items))
|
// fs.Debugf(d.path, "Dir.ReadDirAll OK with %d entries", len(items))
|
||||||
return items, nil
|
return items, nil
|
||||||
|
|
|
@ -91,7 +91,7 @@ func (f *File) Name() (name string) {
|
||||||
// _path returns the full path of the file
|
// _path returns the full path of the file
|
||||||
// use when lock is held
|
// use when lock is held
|
||||||
func (f *File) _path() string {
|
func (f *File) _path() string {
|
||||||
return path.Join(f.d.path, f.leaf)
|
return path.Join(f.d.Path(), f.leaf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path returns the full path of the file
|
// Path returns the full path of the file
|
||||||
|
|
Loading…
Reference in New Issue
Block a user