diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2024-03-21 20:12:31 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 08:12:31 -0700 |
| commit | 25643cfbc6fdde5a73725b557fd2d6ae8e66484f (patch) | |
| tree | dac3c1fd024f71139a2aa0c2108575c8a211338b | |
| parent | 8b18dd940fb28e3c7b949b4efd7fc74301c17bde (diff) | |
| download | seaweedfs-25643cfbc6fdde5a73725b557fd2d6ae8e66484f.tar.xz seaweedfs-25643cfbc6fdde5a73725b557fd2d6ae8e66484f.zip | |
fix: panic: assignment to entry in nil map on S3Sink.CreateEntry (#5406)
| -rw-r--r-- | weed/replication/sink/s3sink/s3_sink.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/weed/replication/sink/s3sink/s3_sink.go b/weed/replication/sink/s3sink/s3_sink.go index 276ea30d6..81acd9a2d 100644 --- a/weed/replication/sink/s3sink/s3_sink.go +++ b/weed/replication/sink/s3sink/s3_sink.go @@ -175,18 +175,23 @@ func (s3sink *S3Sink) CreateEntry(key string, entry *filer_pb.Entry, signatures uploader.PartSize = 0 } } - if _, ok := entry.Extended[s3_constants.AmzUserMetaMtime]; !ok { + + doSaveMtime := true + if entry.Extended == nil { + entry.Extended = make(map[string][]byte) + } else if _, ok := entry.Extended[s3_constants.AmzUserMetaMtime]; ok { + doSaveMtime = false + } + if doSaveMtime { entry.Extended[s3_constants.AmzUserMetaMtime] = []byte(strconv.FormatInt(entry.Attributes.Mtime, 10)) } // process tagging tags := "" - if true { - for k, v := range entry.Extended { - if len(tags) > 0 { - tags = tags + "&" - } - tags = tags + k + "=" + string(v) + for k, v := range entry.Extended { + if len(tags) > 0 { + tags = tags + "&" } + tags = tags + k + "=" + string(v) } // Upload the file to S3. |
