From bc705e14d8ea53931f26a089f4dea00652f206de Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 13 Jun 2022 13:45:19 +0100 Subject: [PATCH] vfscache: fix fatal error: sync: unlock of unlocked mutex error This message is a double panic and was actually caused by an assertion panic in: vfs/vfscache/downloaders/downloaders.go This is triggered by the code added relatively recently to fix a bug with renaming files: ec72432cecdc4eee vfs: fix failed to _ensure cache internal error: downloaders is nil error So it appears that item.o may be nil at this point. This patch detects item.o being nil and fetches it again with NewObject. Fixes #6190 Fixes #6235 --- vfs/vfscache/item.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go index d6a6e20b8..2c8145870 100644 --- a/vfs/vfscache/item.go +++ b/vfs/vfscache/item.go @@ -1131,6 +1131,17 @@ func (item *Item) _ensure(offset, size int64) (err error) { // Downloaders can be nil here if the file has been // renamed, so need to make some more downloaders // OK to call downloaders constructor with item.mu held + + // item.o can also be nil under some circumstances + // See: https://github.com/rclone/rclone/issues/6190 + // See: https://github.com/rclone/rclone/issues/6235 + if item.o == nil { + o, err := item.c.fremote.NewObject(context.Background(), item.name) + if err != nil { + return err + } + item.o = o + } item.downloaders = downloaders.New(item, item.c.opt, item.name, item.o) } return item.downloaders.Download(r)