From 4851c6d62a4481f8d18223b16936cc4f9d53fd44 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 28 Nov 2025 13:11:30 -0800 Subject: [PATCH] refactor: simplify isOrphanedSSES3Header function logic Remove redundant existence check since the caller iterates through metadata map, making the check unnecessary. Improves readability while maintaining the same functionality. --- weed/s3api/s3api_object_handlers_copy.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/weed/s3api/s3api_object_handlers_copy.go b/weed/s3api/s3api_object_handlers_copy.go index 58b67e8d3..0c465d3db 100644 --- a/weed/s3api/s3api_object_handlers_copy.go +++ b/weed/s3api/s3api_object_handlers_copy.go @@ -2367,14 +2367,13 @@ func isOrphanedSSES3Header(headerKey string, metadata map[string][]byte) bool { return false } - // Check if this is an AES256 (SSE-S3) header - if val, exists := metadata[s3_constants.AmzServerSideEncryption]; exists { - if string(val) == "AES256" { - // It's orphaned if the actual key is missing - _, hasKey := metadata[s3_constants.SeaweedFSSSES3Key] - return !hasKey - } + // The header is AmzServerSideEncryption. Check if its value indicates SSE-S3. + if string(metadata[headerKey]) == "AES256" { + // It's an SSE-S3 header. It's orphaned if the actual encryption key is missing. + _, hasKey := metadata[s3_constants.SeaweedFSSSES3Key] + return !hasKey } + return false }