vfs: Fix race condition in vfscache

This commit is contained in:
Nick Craig-Wood 2020-06-23 13:12:13 +01:00
parent 5db15cb157
commit 530dc77cde

View File

@ -488,8 +488,9 @@ func (item *Item) _store(ctx context.Context, storeFn StoreFn) (err error) {
// Object has disappeared if cacheObj == nil // Object has disappeared if cacheObj == nil
if cacheObj != nil { if cacheObj != nil {
o, name := item.o, item.name
item.mu.Unlock() item.mu.Unlock()
o, err := operations.Copy(ctx, item.c.fremote, item.o, item.name, cacheObj) o, err := operations.Copy(ctx, item.c.fremote, o, name, cacheObj)
item.mu.Lock() item.mu.Lock()
if err != nil { if err != nil {
return errors.Wrap(err, "vfs cache: failed to transfer file from cache to remote") return errors.Wrap(err, "vfs cache: failed to transfer file from cache to remote")