From ec72432cecdc4eee9abf25e3fb0119d897b5bba2 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 18 Feb 2022 16:23:26 +0000 Subject: [PATCH] vfs: fix failed to _ensure cache internal error: downloaders is nil error This error was caused by renaming an open file. When the file was renamed in the cache, the downloaders were cleared, however the downloaders were not re-opened when needed again, instead this error was generated. This fix re-opens the downloaders if they have been closed by renaming the file. Fixes #5984 --- vfs/vfscache/item.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go index 6e06bcd51..d2dc5d295 100644 --- a/vfs/vfscache/item.go +++ b/vfs/vfscache/item.go @@ -1128,7 +1128,10 @@ func (item *Item) _ensure(offset, size int64) (err error) { return item.downloaders.EnsureDownloader(r) } if item.downloaders == nil { - return errors.New("internal error: downloaders is nil") + // 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.downloaders = downloaders.New(item, item.c.opt, item.name, item.o) } return item.downloaders.Download(r) }