fix: normalize ETag comparison in multipart upload and replication (#627)

- Normalize ETags by removing quotes before comparison in complete_multipart_upload
- Fix ETag comparison in replication logic to handle quoted ETags from API responses
- Fix ETag comparison in transition object logic
- Add unit tests for trim_etag function

This fixes the ETag mismatch error when uploading large files (5GB+) via multipart upload,
which was caused by PR #592 adding quotes to ETag responses while internal storage remains unquoted.

Fixes #625
This commit is contained in:
安正超
2025-10-08 21:19:57 +08:00
committed by GitHub
parent 626c7ed34a
commit 007d9c0b21
3 changed files with 36 additions and 5 deletions

View File

@@ -276,6 +276,27 @@ pub fn trim_etag(etag: &str) -> String {
mod tests {
use super::*;
#[test]
fn test_trim_etag() {
// Test with quoted ETag
assert_eq!(trim_etag("\"abc123\""), "abc123");
// Test with unquoted ETag
assert_eq!(trim_etag("abc123"), "abc123");
// Test with empty string
assert_eq!(trim_etag(""), "");
// Test with only quotes
assert_eq!(trim_etag("\"\""), "");
// Test with MD5 hash
assert_eq!(trim_etag("\"2c7ab85a893283e98c931e9511add182\""), "2c7ab85a893283e98c931e9511add182");
// Test with multipart ETag format
assert_eq!(trim_etag("\"098f6bcd4621d373cade4e832627b4f6-2\""), "098f6bcd4621d373cade4e832627b4f6-2");
}
#[test]
fn test_base_dir_from_prefix() {
let a = "da/";