Skip to content

Commit

Permalink
vfs: fix failed to _ensure cache internal error: downloaders is nil e…
Browse files Browse the repository at this point in the history
…rror

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 rclone#5984
  • Loading branch information
ncw committed Mar 3, 2022
1 parent 2339172 commit ec72432
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vfs/vfscache/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit ec72432

Please sign in to comment.