fix: adds the surrounding quotes on ETag in PutObject for dir objects and in UploadPartCopy.

Fixes #1277
Fixes #1235

Adds surrounding quotes on `ETag` when creating a directory object. Adds the quotes in `UploadPartCopy` as well.
This commit is contained in:
niksis02
2025-05-09 00:29:23 +04:00
parent 3a9f8c6525
commit 3740d79173
3 changed files with 18 additions and 22 deletions

View File

@@ -19,6 +19,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
"io/fs"
"net/url"
@@ -391,3 +392,14 @@ func MoveFile(source, destination string, perm os.FileMode) error {
return nil
}
// GenerateEtag generates a new quoted etag from the provided hash.Hash
func GenerateEtag(h hash.Hash) string {
dataSum := h.Sum(nil)
return fmt.Sprintf("\"%s\"", hex.EncodeToString(dataSum[:]))
}
// AreEtagsSame compares 2 etags by ignoring quotes
func AreEtagsSame(e1, e2 string) bool {
return strings.Trim(e1, `"`) == strings.Trim(e2, `"`)
}