1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-27 05:33:17 +00:00

hasher: fix crash on object not found

Before this fix `NewObject` could return a wrapped `fs.Object(nil)`
which caused a crash.

This changes the interface of `wrapObject` so it returns an error
which must be checked. This forces the callers to return a `nil`
object rather than an `fs.Object(nil)`.

See: https://forum.rclone.org/t/panic-in-hasher-when-mounting-with-vfs-cache-and-not-synced-data-in-the-cache/29697/11
This commit is contained in:
Nick Craig-Wood
2022-03-12 16:45:25 +00:00
parent 65652f7a75
commit 83ea146ea8
2 changed files with 19 additions and 12 deletions

View File

@@ -210,8 +210,8 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
_ = f.pruneHash(src.Remote())
oResult, err := f.Fs.Put(ctx, wrapIn, src, options...)
o = f.wrapObject(oResult, err)
if o == nil {
o, err = f.wrapObject(oResult, err)
if err != nil {
return nil, err
}