vfs: make File lock and Dir lock not overlap to avoid deadlock

This was caused by this commit which wasn't part of 1.51.0

3c91abce74 vfs: fix race condition caused by unlocked reading of Dir.path
This commit is contained in:
Nick Craig-Wood 2020-04-02 21:14:45 +01:00
parent 2a62471e4c
commit 3911a49256

View File

@ -97,8 +97,9 @@ func (f *File) _path() string {
// Path returns the full path of the file
func (f *File) Path() string {
f.mu.RLock()
defer f.mu.RUnlock()
return f._path()
d, leaf := f.d, f.leaf
f.mu.RUnlock()
return path.Join(d.Path(), leaf)
}
// osPath returns the full path of the file in the cache in OS format