From 6781ef5bd1a86b39469366307b582f342c945c71 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Sat, 19 Aug 2023 04:14:10 +0000 Subject: [PATCH] Reverted to direct array access instead of std::map emplace --- src/s3fs.cpp | 5 ++--- test/integration-test-main.sh | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 96e8709..d5479ea 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -3739,7 +3739,7 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs) // something format error, so skip this. continue; } - xattrs.emplace(std::move(key), std::move(val)); + xattrs[key] = val; } return xattrs.size(); } @@ -3805,8 +3805,7 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v parse_xattrs(strxattrs, xattrs); // add name(do not care overwrite and empty name/value) - std::string val(value, size); - xattrs.emplace(name, std::move(val)); + xattrs[name] = std::string(value, size); // build new strxattrs(not encoded) and set it to headers_t meta["x-amz-meta-xattr"] = build_xattrs(xattrs); diff --git a/test/integration-test-main.sh b/test/integration-test-main.sh index e86080e..1c32b2e 100755 --- a/test/integration-test-main.sh +++ b/test/integration-test-main.sh @@ -815,6 +815,10 @@ function test_extended_attributes { touch "${TEST_TEXT_FILE}" # set value + set_xattr key1 value0 "${TEST_TEXT_FILE}" + get_xattr key1 "${TEST_TEXT_FILE}" | grep -q '^value0$' + + # over write value set_xattr key1 value1 "${TEST_TEXT_FILE}" get_xattr key1 "${TEST_TEXT_FILE}" | grep -q '^value1$'