From 488ed2863544d6d8819c812bd85a3632d5545d41 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 15 May 2024 15:55:05 +0100 Subject: [PATCH] fs: fix panic when using --metadata-mapper on large google doc files Before this change, attempting to copy a large google doc while using the metadata mapper caused a panic. Google doc files use Rcat to download as they have an unknown size, and when the size of the doc file got above --streaming-upload-cutoff it used a object.NewStaticObjectInfo with a `nil` Fs to upload the file which caused the crash in the metadata mapper code. This change makes sure that the Fs in object.NewStaticObjectInfo is never nil, and it returns MemoryFs which is consistent with the Rcat code when the source is sized below the --streaming-upload-cutoff threshold. Fixes #7845 --- fs/object/object.go | 3 +++ fs/object/object_test.go | 1 + 2 files changed, 4 insertions(+) diff --git a/fs/object/object.go b/fs/object/object.go index 93c923681..01b38f57a 100644 --- a/fs/object/object.go +++ b/fs/object/object.go @@ -43,6 +43,9 @@ func NewStaticObjectInfo(remote string, modTime time.Time, size int64, storable info.hashes[ht] = "" } } + if f == nil { + info.fs = MemoryFs + } return info } diff --git a/fs/object/object_test.go b/fs/object/object_test.go index 1e5ca75c4..64bb36140 100644 --- a/fs/object/object_test.go +++ b/fs/object/object_test.go @@ -34,6 +34,7 @@ func TestStaticObject(t *testing.T) { o = object.NewStaticObjectInfo(remote, now, size, true, nil, nil) _, err = o.Hash(context.Background(), hash.MD5) assert.Equal(t, hash.ErrUnsupported, err) + assert.Equal(t, object.MemoryFs, o.Fs()) hs := map[hash.Type]string{ hash.MD5: "potato",