From 3daf62cf3d691e9a6dcf7a5063c9fe27a06bc5d0 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 2 Feb 2025 11:14:38 +0000 Subject: [PATCH] b2: fix "fatal error: concurrent map writes" - fixes #8355 This was caused by the embryonic metadata support. Since this isn't actually visible externally, this patch removes it for the time being. --- backend/b2/b2.go | 25 +++++++------------------ backend/b2/b2_internal_test.go | 6 ------ 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/backend/b2/b2.go b/backend/b2/b2.go index ad58383f9..357b6c6c8 100644 --- a/backend/b2/b2.go +++ b/backend/b2/b2.go @@ -300,14 +300,13 @@ type Fs struct { // Object describes a b2 object type Object struct { - fs *Fs // what this object is part of - remote string // The remote path - id string // b2 id of the file - modTime time.Time // The modified time of the object if known - sha1 string // SHA-1 hash if known - size int64 // Size of the object - mimeType string // Content-Type of the object - meta map[string]string // The object metadata if known - may be nil - with lower case keys + fs *Fs // what this object is part of + remote string // The remote path + id string // b2 id of the file + modTime time.Time // The modified time of the object if known + sha1 string // SHA-1 hash if known + size int64 // Size of the object + mimeType string // Content-Type of the object } // ------------------------------------------------------------ @@ -1605,9 +1604,6 @@ func (o *Object) decodeMetaDataRaw(ID, SHA1 string, Size int64, UploadTimestamp if err != nil { return err } - // For now, just set "mtime" in metadata - o.meta = make(map[string]string, 1) - o.meta["mtime"] = o.modTime.Format(time.RFC3339Nano) return nil } @@ -1887,13 +1883,6 @@ func (o *Object) getOrHead(ctx context.Context, method string, options []fs.Open Info: Info, } - // Embryonic metadata support - just mtime - o.meta = make(map[string]string, 1) - modTime, err := parseTimeStringHelper(info.Info[timeKey]) - if err == nil { - o.meta["mtime"] = modTime.Format(time.RFC3339Nano) - } - // When reading files from B2 via cloudflare using // --b2-download-url cloudflare strips the Content-Length // headers (presumably so it can inject stuff) so use the old diff --git a/backend/b2/b2_internal_test.go b/backend/b2/b2_internal_test.go index c470dcc4d..168f61233 100644 --- a/backend/b2/b2_internal_test.go +++ b/backend/b2/b2_internal_test.go @@ -258,12 +258,6 @@ func (f *Fs) internalTestMetadata(t *testing.T, size string, uploadCutoff string assert.Equal(t, v, got, k) } - // mtime - for k, v := range metadata { - got := o.meta[k] - assert.Equal(t, v, got, k) - } - assert.Equal(t, mimeType, gotMetadata.ContentType, "Content-Type") // Modification time from the x-bz-info-src_last_modified_millis header