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:

ec72432cec 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
This commit is contained in:
Nick Craig-Wood 2022-06-13 13:45:19 +01:00
parent ea5bb79366
commit bc705e14d8

View File

@ -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)