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