Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix: panic: assignment to entry in nil map on S3Sink.CreateEntry (#5406)

Konstantin Lebedev25643cfbc6fd
diff --git a/weed/replication/sink/s3sink/s3_sink.go b/weed/replication/sink/s3sink/s3_sink.go
index 276ea30d6d..81acd9a2d6 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.