diff --git a/repertory/librepertory/src/providers/s3/s3_provider.cpp b/repertory/librepertory/src/providers/s3/s3_provider.cpp index 5e05efa2..187ce69c 100644 --- a/repertory/librepertory/src/providers/s3/s3_provider.cpp +++ b/repertory/librepertory/src/providers/s3/s3_provider.cpp @@ -542,18 +542,11 @@ auto s3_provider::get_file(const std::string &api_path, api_file &file) const file.accessed_date = file.changed_date = file.creation_date = file.modified_date = result.last_modified; file.key = is_encrypted ? utils::path::create_api_path(object_name) : ""; - - std::string size_str; - if (get_item_meta(file.api_path, META_SIZE, size_str) == - api_error::success) { - file.file_size = utils::string::to_uint64(size_str); - } else { - file.file_size = - is_encrypted - ? utils::encryption::encrypting_reader::calculate_decrypted_size( - result.content_length, not legacy_bucket_) - : result.content_length; - } + file.file_size = + is_encrypted + ? utils::encryption::encrypting_reader::calculate_decrypted_size( + result.content_length, not legacy_bucket_) + : result.content_length; return add_if_not_found(file, object_name); } catch (const std::exception &e) { diff --git a/repertory/repertory_test/src/providers_test.cpp b/repertory/repertory_test/src/providers_test.cpp index f98ba36f..27e03a8c 100644 --- a/repertory/repertory_test/src/providers_test.cpp +++ b/repertory/repertory_test/src/providers_test.cpp @@ -753,6 +753,7 @@ static void get_file_size(i_provider &provider) { auto &file = test::create_random_file(128U); auto api_path = fmt::format("/{}", utils::path::strip_to_file_name(file.get_path())); + create_file(provider, api_path); stop_type stop_requested{false}; auto res = provider.upload_file(api_path, file.get_path(), stop_requested); @@ -808,20 +809,24 @@ static void get_filesystem_item(i_provider &provider) { return; } - auto &src = test::create_random_file(128U); + auto &file = test::create_random_file(128U); auto api_path = - fmt::format("/{}", utils::path::strip_to_file_name(src.get_path())); + fmt::format("/{}", utils::path::strip_to_file_name(file.get_path())); + create_file(provider, api_path); stop_type stop_requested{false}; - auto res = provider.upload_file(api_path, src.get_path(), stop_requested); + auto res = provider.upload_file(api_path, file.get_path(), stop_requested); ASSERT_EQ(api_error::success, res); + EXPECT_EQ(api_error::success, + provider.set_item_meta(api_path, META_SIZE, + std::to_string(*file.size()))); filesystem_item fsi{}; res = provider.get_filesystem_item(api_path, false, fsi); EXPECT_EQ(api_error::success, res); EXPECT_EQ(api_path, fsi.api_path); EXPECT_FALSE(fsi.directory); - EXPECT_EQ(*src.size(), fsi.size); + EXPECT_EQ(*file.size(), fsi.size); res = provider.remove_file(api_path); EXPECT_EQ(api_error::success, res); @@ -882,6 +887,7 @@ static void get_filesystem_item_from_source_path(const app_config &cfg, api_path = fmt::format("/{}", utils::path::strip_to_file_name(file.get_path())); source_path = file.get_path(); + create_file(provider, api_path); EXPECT_EQ( api_error::success,