vfs: re-use the File objects when re-reading the directory

Make it so that d.items is never nil to simplify the code

This should help with inconsistent reads when the source object changes.
This commit is contained in:
Nick Craig-Wood
2018-03-01 15:51:05 +00:00
parent 7fb53a031c
commit 5e334eedd2
2 changed files with 37 additions and 33 deletions

View File

@@ -252,6 +252,14 @@ func (f *File) setObject(o fs.Object) {
f.d.addObject(f)
}
// Update the object but don't update the directory cache - for use by
// the directory cache
func (f *File) setObjectNoUpdate(o fs.Object) {
f.mu.Lock()
defer f.mu.Unlock()
f.o = o
}
// Get the current fs.Object - may be nil
func (f *File) getObject() fs.Object {
f.mu.Lock()