refactor
This commit is contained in:
parent
bb8cbb49f5
commit
739a1103f0
@ -49,8 +49,9 @@ private:
|
||||
void remove_deleted_files(bool source_only);
|
||||
|
||||
protected:
|
||||
[[nodiscard]] static auto create_api_file(std::string path, std::string key,
|
||||
std::uint64_t size) -> api_file;
|
||||
[[nodiscard]] static auto
|
||||
create_api_file(std::string path, std::string key, std::uint64_t size,
|
||||
std::uint64_t file_time) -> api_file;
|
||||
|
||||
[[nodiscard]] static auto create_api_file(std::string path,
|
||||
std::uint64_t size,
|
||||
|
@ -33,14 +33,15 @@
|
||||
|
||||
namespace repertory {
|
||||
auto base_provider::create_api_file(std::string path, std::string key,
|
||||
std::uint64_t size) -> api_file {
|
||||
std::uint64_t size,
|
||||
std::uint64_t file_time) -> api_file {
|
||||
api_file file{};
|
||||
file.api_path = utils::path::create_api_path(path);
|
||||
file.api_parent = utils::path::get_parent_api_path(file.api_path);
|
||||
file.accessed_date = utils::time::get_time_now();
|
||||
file.changed_date = utils::time::get_time_now();
|
||||
file.creation_date = utils::time::get_time_now();
|
||||
file.modified_date = utils::time::get_time_now();
|
||||
file.accessed_date = file_time;
|
||||
file.changed_date = file_time;
|
||||
file.creation_date = file_time;
|
||||
file.modified_date = file_time;
|
||||
file.key = key;
|
||||
file.file_size = size;
|
||||
return file;
|
||||
@ -691,7 +692,7 @@ auto base_provider::start(api_item_added_callback api_item_added,
|
||||
|
||||
api_meta_map meta{};
|
||||
if (get_item_meta("/", meta) == api_error::item_not_found) {
|
||||
auto dir = create_api_file("/", "", 0U);
|
||||
auto dir = create_api_file("/", "", 0U, utils::time::get_time_now());
|
||||
api_item_added_(true, dir);
|
||||
}
|
||||
|
||||
|
@ -194,9 +194,8 @@ auto s3_provider::create_path_directories(
|
||||
api_meta_map meta{};
|
||||
auto res = get_item_meta(cur_path, meta);
|
||||
if (res == api_error::item_not_found) {
|
||||
auto dir = create_api_file(cur_path, cur_key, 0U);
|
||||
dir.accessed_date = dir.changed_date = dir.creation_date =
|
||||
dir.modified_date = get_last_modified(true, cur_path);
|
||||
auto dir = create_api_file(cur_path, cur_key, 0U,
|
||||
get_last_modified(true, cur_path));
|
||||
get_api_item_added()(true, dir);
|
||||
continue;
|
||||
}
|
||||
@ -355,9 +354,8 @@ auto s3_provider::get_directory_items_impl(
|
||||
}
|
||||
} else {
|
||||
auto file =
|
||||
create_api_file(child_api_path, child_object_name, dir_item.size);
|
||||
file.accessed_date = file.changed_date = file.creation_date =
|
||||
file.modified_date = last_modified;
|
||||
create_api_file(child_api_path, child_object_name, dir_item.size,
|
||||
get_last_modified(true, child_api_path));
|
||||
ret = add_if_not_found(file, child_object_name);
|
||||
if (ret != api_error::success) {
|
||||
return ret;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "utils/path.hpp"
|
||||
#include "utils/polling.hpp"
|
||||
#include "utils/string.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
namespace repertory {
|
||||
@ -132,9 +133,10 @@ auto sia_provider::get_directory_items_impl(
|
||||
|
||||
api_meta_map meta{};
|
||||
if (get_item_meta(entry_api_path, meta) == api_error::item_not_found) {
|
||||
file = create_api_file(
|
||||
entry_api_path, "",
|
||||
directory ? 0U : entry["size"].get<std::uint64_t>());
|
||||
file = create_api_file(entry_api_path, "",
|
||||
directory ? 0U
|
||||
: entry["size"].get<std::uint64_t>(),
|
||||
utils::time::get_time_now());
|
||||
get_api_item_added()(directory, file);
|
||||
auto res = get_item_meta(entry_api_path, meta);
|
||||
if (res != api_error::success) {
|
||||
@ -185,7 +187,7 @@ auto sia_provider::get_file(const std::string &api_path,
|
||||
|
||||
api_meta_map meta{};
|
||||
if (get_item_meta(api_path, meta) == api_error::item_not_found) {
|
||||
file = create_api_file(api_path, "", size);
|
||||
file = create_api_file(api_path, "", size, utils::time::get_time_now());
|
||||
get_api_item_added()(false, file);
|
||||
} else {
|
||||
file = create_api_file(api_path, size, meta);
|
||||
@ -220,7 +222,8 @@ auto sia_provider::get_file_list(api_file_list &list) const -> api_error {
|
||||
api_meta_map meta{};
|
||||
if (get_item_meta(entry_api_path, meta) ==
|
||||
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_api_item_added()(true, dir);
|
||||
}
|
||||
|
||||
@ -236,7 +239,8 @@ auto sia_provider::get_file_list(api_file_list &list) const -> api_error {
|
||||
if (get_item_meta(entry_api_path, meta) ==
|
||||
api_error::item_not_found) {
|
||||
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_api_item_added()(false, file);
|
||||
} else {
|
||||
file = create_api_file(entry_api_path,
|
||||
|
Loading…
x
Reference in New Issue
Block a user