This commit is contained in:
parent
51cb2c0b9a
commit
692c92b0df
@ -26,6 +26,7 @@
|
|||||||
#include "events/events.hpp"
|
#include "events/events.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "providers/base_provider.hpp"
|
#include "providers/base_provider.hpp"
|
||||||
|
#include "providers/s3/s3_provider.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
#include "utils/file_utils.hpp"
|
#include "utils/file_utils.hpp"
|
||||||
@ -35,6 +36,18 @@
|
|||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
[[nodiscard]] auto
|
||||||
|
get_last_modified(const nlohmann::json &obj) -> std::uint64_t {
|
||||||
|
try {
|
||||||
|
return repertory::s3_provider::convert_api_date(
|
||||||
|
obj["modTime"].get<std::string>());
|
||||||
|
} catch (...) {
|
||||||
|
return repertory::utils::time::get_time_now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
sia_provider::sia_provider(app_config &config, i_http_comm &comm)
|
sia_provider::sia_provider(app_config &config, i_http_comm &comm)
|
||||||
: base_provider(config, comm) {}
|
: base_provider(config, comm) {}
|
||||||
@ -130,13 +143,12 @@ auto sia_provider::get_directory_items_impl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
api_file file{};
|
api_file file{};
|
||||||
|
|
||||||
api_meta_map meta{};
|
api_meta_map meta{};
|
||||||
if (get_item_meta(entry_api_path, meta) == api_error::item_not_found) {
|
if (get_item_meta(entry_api_path, meta) == api_error::item_not_found) {
|
||||||
file = create_api_file(entry_api_path, "",
|
file = create_api_file(entry_api_path, "",
|
||||||
directory ? 0U
|
directory ? 0U
|
||||||
: entry["size"].get<std::uint64_t>(),
|
: entry["size"].get<std::uint64_t>(),
|
||||||
utils::time::get_time_now());
|
get_last_modified(entry));
|
||||||
get_api_item_added()(directory, file);
|
get_api_item_added()(directory, file);
|
||||||
auto res = get_item_meta(entry_api_path, meta);
|
auto res = get_item_meta(entry_api_path, meta);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
@ -187,7 +199,8 @@ auto sia_provider::get_file(const std::string &api_path,
|
|||||||
|
|
||||||
api_meta_map meta{};
|
api_meta_map meta{};
|
||||||
if (get_item_meta(api_path, meta) == api_error::item_not_found) {
|
if (get_item_meta(api_path, meta) == api_error::item_not_found) {
|
||||||
file = create_api_file(api_path, "", size, utils::time::get_time_now());
|
file = create_api_file(api_path, "", size,
|
||||||
|
get_last_modified(file_data["object"]));
|
||||||
get_api_item_added()(false, file);
|
get_api_item_added()(false, file);
|
||||||
} else {
|
} else {
|
||||||
file = create_api_file(api_path, size, meta);
|
file = create_api_file(api_path, size, meta);
|
||||||
@ -223,7 +236,7 @@ auto sia_provider::get_file_list(api_file_list &list) const -> api_error {
|
|||||||
if (get_item_meta(entry_api_path, meta) ==
|
if (get_item_meta(entry_api_path, meta) ==
|
||||||
api_error::item_not_found) {
|
api_error::item_not_found) {
|
||||||
auto dir = create_api_file(entry_api_path, "", 0U,
|
auto dir = create_api_file(entry_api_path, "", 0U,
|
||||||
utils::time::get_time_now());
|
get_last_modified(entry));
|
||||||
get_api_item_added()(true, dir);
|
get_api_item_added()(true, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +253,7 @@ auto sia_provider::get_file_list(api_file_list &list) const -> api_error {
|
|||||||
api_error::item_not_found) {
|
api_error::item_not_found) {
|
||||||
file = create_api_file(entry_api_path, "",
|
file = create_api_file(entry_api_path, "",
|
||||||
entry["size"].get<std::uint64_t>(),
|
entry["size"].get<std::uint64_t>(),
|
||||||
utils::time::get_time_now());
|
get_last_modified(entry));
|
||||||
get_api_item_added()(false, file);
|
get_api_item_added()(false, file);
|
||||||
} else {
|
} else {
|
||||||
file = create_api_file(entry_api_path,
|
file = create_api_file(entry_api_path,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user