From 530dc77cdefdadc94ec76b7463bfb1bb1506226c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 23 Jun 2020 13:12:13 +0100 Subject: [PATCH] vfs: Fix race condition in vfscache --- vfs/vfscache/item.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go index 9d27d57c8..ca759ba67 100644 --- a/vfs/vfscache/item.go +++ b/vfs/vfscache/item.go @@ -488,8 +488,9 @@ func (item *Item) _store(ctx context.Context, storeFn StoreFn) (err error) { // Object has disappeared if cacheObj == nil if cacheObj != nil { + o, name := item.o, item.name 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() if err != nil { return errors.Wrap(err, "vfs cache: failed to transfer file from cache to remote")