diff --git a/cmake/versions.cmake b/cmake/versions.cmake index 7b24f207..01c6d81b 100644 --- a/cmake/versions.cmake +++ b/cmake/versions.cmake @@ -1,15 +1,15 @@ set(BINUTILS_VERSION 2.44) -set(BOOST_MAJOR_VERSION 1) -set(BOOST_MINOR_VERSION 88) -set(BOOST_PATCH_VERSION 0) set(BOOST2_MAJOR_VERSION 1) set(BOOST2_MINOR_VERSION 76) set(BOOST2_PATCH_VERSION 0) +set(BOOST_MAJOR_VERSION 1) +set(BOOST_MINOR_VERSION 88) +set(BOOST_PATCH_VERSION 0) set(CPP_HTTPLIB_VERSION 0.23.1) -set(CURL_VERSION 8.15.0) set(CURL2_VERSION 8_15_0) -set(EXPAT_VERSION 2.7.1) +set(CURL_VERSION 8.15.0) set(EXPAT2_VERSION 2_7_1) +set(EXPAT_VERSION 2.7.1) set(GCC_VERSION 15.1.0) set(GTEST_VERSION 1.17.0) set(ICU_VERSION 76-1) @@ -22,9 +22,9 @@ set(PKG_CONFIG_VERSION 0.29.2) set(PUGIXML_VERSION 1.15) set(ROCKSDB_VERSION 10.4.2) set(SPDLOG_VERSION 1.15.3) -set(SQLITE_VERSION 3500300) set(SQLITE2_VERSION 3.50.3) +set(SQLITE_VERSION 3500300) set(STDUUID_VERSION 1.2.3) -set(WINFSP_VERSION 2.1.25156) set(WINFSP2_VERSION 2.1) +set(WINFSP_VERSION 2.1.25156) set(ZLIB_VERSION 1.3.1) diff --git a/repertory/librepertory/include/platform/unix_platform.hpp b/repertory/librepertory/include/platform/unix_platform.hpp index d97da6c8..fe81efc6 100644 --- a/repertory/librepertory/include/platform/unix_platform.hpp +++ b/repertory/librepertory/include/platform/unix_platform.hpp @@ -75,9 +75,9 @@ public: std::uint64_t accessed_date, std::uint32_t attributes, std::uint64_t changed_date, std::uint64_t creation_date, bool directory, std::uint32_t gid, const std::string &key, std::uint32_t mode, - std::uint64_t modified_date, std::uint32_t osx_backup, - std::uint32_t osx_flags, std::uint64_t size, const std::string &source_path, - std::uint32_t uid, std::uint64_t written_date) -> api_meta_map; + std::uint64_t modified_date, std::uint32_t osx_flags, std::uint64_t size, + const std::string &source_path, std::uint32_t uid, + std::uint64_t written_date) -> api_meta_map; [[nodiscard]] auto provider_meta_creator(bool directory, const api_file &file) -> api_meta_map; diff --git a/repertory/librepertory/include/platform/win32_platform.hpp b/repertory/librepertory/include/platform/win32_platform.hpp index ee3da061..7da2c3c3 100644 --- a/repertory/librepertory/include/platform/win32_platform.hpp +++ b/repertory/librepertory/include/platform/win32_platform.hpp @@ -62,9 +62,9 @@ public: std::uint64_t accessed_date, std::uint32_t attributes, std::uint64_t changed_date, std::uint64_t creation_date, bool directory, std::uint32_t gid, const std::string &key, std::uint32_t mode, - std::uint64_t modified_date, std::uint32_t osx_backup, - std::uint32_t osx_flags, std::uint64_t size, const std::string &source_path, - std::uint32_t uid, std::uint64_t written_date) -> api_meta_map; + std::uint64_t modified_date, std::uint32_t osx_flags, std::uint64_t size, + const std::string &source_path, std::uint32_t uid, + std::uint64_t written_date) -> api_meta_map; [[nodiscard]] auto provider_meta_creator(bool directory, const api_file &file) -> api_meta_map; diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 44558232..b9dc2a64 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -263,6 +263,7 @@ struct api_file final { std::string key; std::uint64_t modified_date{}; std::string source_path; + std::uint64_t written_date{}; }; struct directory_item final { diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index 45eed6b8..d8d4560f 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -220,7 +220,7 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode, auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_ARCHIVE, now, now, is_directory_op, - get_effective_gid(), "", mode, now, 0U, osx_flags, 0U, + get_effective_gid(), "", mode, now, osx_flags, 0U, utils::path::combine(config_.get_cache_directory(), {utils::create_uuid_string()}), get_effective_uid(), now); @@ -705,7 +705,7 @@ auto fuse_drive::mkdir_impl(std::string api_path, mode_t mode) -> api_error { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_DIRECTORY, now, now, true, get_effective_gid(), "", mode, now, - 0U, 0U, 0U, "", get_effective_uid(), now); + 0U, 0U, "", get_effective_uid(), now); res = provider_.create_directory(api_path, meta); if (res != api_error::success) { return res; diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp index 927685dc..f8d69972 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp @@ -342,15 +342,15 @@ void fuse_drive_base::populate_stat(const std::string &api_path, u_stat->st_blksize = 0; u_stat->st_flags = get_flags_from_meta(meta); - set_timespec_from_meta(meta, META_MODIFIED, u_stat->st_mtimespec); - set_timespec_from_meta(meta, META_CREATION, u_stat->st_birthtimespec); - set_timespec_from_meta(meta, META_CHANGED, u_stat->st_ctimespec); set_timespec_from_meta(meta, META_ACCESSED, u_stat->st_atimespec); + set_timespec_from_meta(meta, META_CHANGED, u_stat->st_ctimespec); + set_timespec_from_meta(meta, META_CREATION, u_stat->st_birthtimespec); + set_timespec_from_meta(meta, META_MODIFIED, u_stat->st_mtimespec); #else // !defined(__APPLE__) u_stat->st_blksize = 4096; set_timespec_from_meta(meta, META_MODIFIED, u_stat->st_mtim); - set_timespec_from_meta(meta, META_CREATION, u_stat->st_ctim); + set_timespec_from_meta(meta, META_CHANGED, u_stat->st_ctim); set_timespec_from_meta(meta, META_ACCESSED, u_stat->st_atim); #endif // defined(__APPLE__) } diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp index db6d6331..d0a5e5d3 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp @@ -119,7 +119,7 @@ void remote_server::populate_file_info(const std::string &api_path, utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) * WINFSP_ALLOCATION_UNIT; r_info.ChangeTime = utils::time::unix_time_to_windows_time( - utils::string::to_uint64(empty_as_zero(meta[META_MODIFIED]))); + utils::string::to_uint64(empty_as_zero(meta[META_CHANGED]))); r_info.CreationTime = utils::time::unix_time_to_windows_time( utils::string::to_uint64(empty_as_zero(meta[META_CREATION]))); r_info.EaSize = 0; @@ -1720,26 +1720,26 @@ auto remote_server::update_to_windows_format(const std::string &root_api_path, item[JSON_META] = meta; } - item[JSON_META][META_ACCESSED] = std::to_string( - utils::string::to_uint64(empty_as_zero(item[JSON_META][META_ACCESSED]))); - item[JSON_META][META_CREATION] = std::to_string( - utils::string::to_uint64(empty_as_zero(item[JSON_META][META_CREATION]))); - item[JSON_META][META_MODIFIED] = std::to_string( - utils::string::to_uint64(empty_as_zero(item[JSON_META][META_MODIFIED]))); - auto update_meta{false}; - if (item[JSON_META][META_WRITTEN].empty() || - (item[JSON_META][META_WRITTEN].get() == "0") || - (item[JSON_META][META_WRITTEN].get() == - std::to_string(utils::time::WIN32_TIME_CONVERSION))) { - item[JSON_META][META_WRITTEN] = - item[JSON_META][META_MODIFIED].get(); - update_meta = true; - } + auto default_value = std::to_string(utils::time::get_time_now()); + const auto ensure_set = [&item, &update_meta]( + const std::string &name, + const std::string &default_value, bool as_time) { + if (not item[JSON_META].contains(name) || item[JSON_META][name].empty() || + (as_time && (item[JSON_META][name].template get() == "0" || + item[JSON_META][name].template get() == + std::to_string(utils::time::WIN32_TIME_CONVERSION)))) { + item[JSON_META][name] = default_value; + update_meta = true; + } + }; - if (item[JSON_META][META_ATTRIBUTES].empty()) { - item[JSON_META][META_ATTRIBUTES] = "0"; - } + ensure_set(META_ACCESSED, default_value, true); + ensure_set(META_CREATION, default_value, true); + ensure_set(META_MODIFIED, default_value, true); + ensure_set(META_CHANGED, item[JSON_META][META_MODIFIED], true); + ensure_set(META_WRITTEN, item[JSON_META][META_MODIFIED], true); + ensure_set(META_ATTRIBUTES, "0", false); auto attributes = utils::string::to_uint32( item[JSON_META][META_ATTRIBUTES].get()); diff --git a/repertory/librepertory/src/platform/unix_platform.cpp b/repertory/librepertory/src/platform/unix_platform.cpp index 7486e1fb..3ee57335 100644 --- a/repertory/librepertory/src/platform/unix_platform.cpp +++ b/repertory/librepertory/src/platform/unix_platform.cpp @@ -207,22 +207,22 @@ auto lock_data::wait_for_lock(int handle, std::uint8_t retry_count) -> int { return lock_status; } -auto create_meta_attributes( - std::uint64_t accessed_date, std::uint32_t attributes, - std::uint64_t changed_date, std::uint64_t creation_date, bool directory, - std::uint32_t gid, const std::string &key, std::uint32_t mode, - std::uint64_t modified_date, std::uint32_t osx_backup, - std::uint32_t osx_flags, std::uint64_t size, const std::string &source_path, - std::uint32_t uid, std::uint64_t written_date) -> api_meta_map { - return { +auto create_meta_attributes(std::uint64_t accessed_date, + std::uint32_t attributes, + std::uint64_t changed_date, + std::uint64_t creation_date, bool directory, + std::uint32_t gid, const std::string &key, + std::uint32_t mode, std::uint64_t modified_date, + std::uint32_t osx_flags, std::uint64_t size, + const std::string &source_path, std::uint32_t uid, + std::uint64_t written_date) -> api_meta_map { + api_meta_map meta{ {META_ACCESSED, std::to_string(accessed_date)}, {META_ATTRIBUTES, std::to_string(attributes)}, - {META_BACKUP, std::to_string(osx_backup)}, {META_CHANGED, std::to_string(changed_date)}, {META_CREATION, std::to_string(creation_date)}, {META_DIRECTORY, utils::string::from_bool(directory)}, {META_GID, std::to_string(gid)}, - {META_KDF, ""}, {META_KEY, key}, {META_MODE, std::to_string(mode)}, {META_MODIFIED, std::to_string(modified_date)}, @@ -233,6 +233,14 @@ auto create_meta_attributes( {META_UID, std::to_string(uid)}, {META_WRITTEN, std::to_string(written_date)}, }; + + for (const auto &name : META_USED_NAMES) { + if (not meta.contains(name)) { + meta[name] = ""; + } + } + + return meta; } auto provider_meta_creator(bool directory, const api_file &file) @@ -243,8 +251,8 @@ auto provider_meta_creator(bool directory, const api_file &file) file.changed_date, file.creation_date, directory, getgid(), file.key, directory ? S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR : S_IFREG | S_IRUSR | S_IWUSR, - file.modified_date, 0U, 0U, file.file_size, file.source_path, getuid(), - file.modified_date); + file.modified_date, 0U, file.file_size, file.source_path, getuid(), + file.written_date); } auto provider_meta_handler(i_provider &provider, bool directory, diff --git a/repertory/librepertory/src/platform/win32_platform.cpp b/repertory/librepertory/src/platform/win32_platform.cpp index 17250082..d9798c11 100644 --- a/repertory/librepertory/src/platform/win32_platform.cpp +++ b/repertory/librepertory/src/platform/win32_platform.cpp @@ -189,22 +189,22 @@ auto lock_data::set_mount_state(bool active, std::string_view mount_location, return ret; } -auto create_meta_attributes( - std::uint64_t accessed_date, std::uint32_t attributes, - std::uint64_t changed_date, std::uint64_t creation_date, bool directory, - std::uint32_t gid, const std::string &key, std::uint32_t mode, - std::uint64_t modified_date, std::uint32_t osx_backup, - std::uint32_t osx_flags, std::uint64_t size, const std::string &source_path, - std::uint32_t uid, std::uint64_t written_date) -> api_meta_map { - return { +auto create_meta_attributes(std::uint64_t accessed_date, + std::uint32_t attributes, + std::uint64_t changed_date, + std::uint64_t creation_date, bool directory, + std::uint32_t gid, const std::string &key, + std::uint32_t mode, std::uint64_t modified_date, + std::uint32_t osx_flags, std::uint64_t size, + const std::string &source_path, std::uint32_t uid, + std::uint64_t written_date) -> api_meta_map { + api_meta_map meta{ {META_ACCESSED, std::to_string(accessed_date)}, {META_ATTRIBUTES, std::to_string(attributes)}, - {META_BACKUP, std::to_string(osx_backup)}, {META_CHANGED, std::to_string(changed_date)}, {META_CREATION, std::to_string(creation_date)}, {META_DIRECTORY, utils::string::from_bool(directory)}, {META_GID, std::to_string(gid)}, - {META_KDF, ""}, {META_KEY, key}, {META_MODE, std::to_string(mode)}, {META_MODIFIED, std::to_string(modified_date)}, @@ -215,6 +215,14 @@ auto create_meta_attributes( {META_UID, std::to_string(uid)}, {META_WRITTEN, std::to_string(written_date)}, }; + + for (const auto &name : META_USED_NAMES) { + if (not meta.contains(name)) { + meta[name] = ""; + } + } + + return meta; } auto provider_meta_creator(bool directory, const api_file &file) @@ -223,8 +231,8 @@ auto provider_meta_creator(bool directory, const api_file &file) file.accessed_date, directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_ARCHIVE, file.changed_date, file.creation_date, directory, 0u, file.key, - directory ? S_IFDIR : S_IFREG, file.modified_date, 0u, 0u, file.file_size, - file.source_path, 0u, file.modified_date); + directory ? S_IFDIR : S_IFREG, file.modified_date, 0u, file.file_size, + file.source_path, 0u, file.written_date); } auto provider_meta_handler(i_provider &provider, bool directory, diff --git a/repertory/librepertory/src/providers/base_provider.cpp b/repertory/librepertory/src/providers/base_provider.cpp index e9d0e98a..68dd6dab 100644 --- a/repertory/librepertory/src/providers/base_provider.cpp +++ b/repertory/librepertory/src/providers/base_provider.cpp @@ -72,15 +72,19 @@ void base_provider::add_all_items(stop_type &stop_requested) { auto base_provider::create_api_file(std::string path, std::string key, 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 = file_time; - file.changed_date = file_time; - file.creation_date = file_time; - file.modified_date = file_time; - file.key = key; - file.file_size = size; + auto api_path = utils::path::create_api_path(path); + api_file file{ + .api_path = api_path, + .api_parent = utils::path::get_parent_api_path(api_path), + .accessed_date = file_time, + .changed_date = file_time, + .creation_date = file_time, + .file_size = size, + .key = key, + .modified_date = file_time, + .source_path = "", + .written_date = file_time, + }; return file; } @@ -91,14 +95,19 @@ auto base_provider::create_api_file(std::string path, std::uint64_t size, current_size = size; } - 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::string::to_uint64(meta[META_ACCESSED]); - file.changed_date = utils::string::to_uint64(meta[META_CHANGED]); - file.creation_date = utils::string::to_uint64(meta[META_CREATION]); - file.file_size = current_size; - file.modified_date = utils::string::to_uint64(meta[META_MODIFIED]); + auto api_path = utils::path::create_api_path(path); + api_file file{ + .api_path = api_path, + .api_parent = utils::path::get_parent_api_path(api_path), + .accessed_date = utils::string::to_uint64(meta[META_ACCESSED]), + .changed_date = utils::string::to_uint64(meta[META_CHANGED]), + .creation_date = utils::string::to_uint64(meta[META_CREATION]), + .file_size = current_size, + .key = "", + .modified_date = utils::string::to_uint64(meta[META_MODIFIED]), + .source_path = "", + .written_date = utils::string::to_uint64(meta[META_WRITTEN]), + }; return file; } diff --git a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp index 6caf5198..a92ed03e 100644 --- a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp +++ b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp @@ -57,19 +57,22 @@ auto encrypt_provider::create_api_file(const std::string &api_path, throw std::runtime_error("failed to get file times"); } - api_file file{}; - file.accessed_date = times->get(utils::file::time_type::accessed); - file.api_path = api_path; - file.api_parent = utils::path::get_parent_api_path(api_path); - file.changed_date = times->get(utils::file::time_type::modified); - file.creation_date = times->get(utils::file::time_type::created); - file.file_size = - directory - ? 0U - : utils::encryption::encrypting_reader::calculate_encrypted_size( - source_path, true); - file.modified_date = times->get(utils::file::time_type::written); - file.source_path = source_path; + api_file file{ + .api_path = api_path, + .api_parent = utils::path::get_parent_api_path(api_path), + .accessed_date = times->get(utils::file::time_type::accessed), + .changed_date = times->get(utils::file::time_type::changed), + .creation_date = times->get(utils::file::time_type::created), + .file_size = + directory + ? 0U + : utils::encryption::encrypting_reader::calculate_encrypted_size( + source_path, true), + .key = "", + .modified_date = times->get(utils::file::time_type::modified), + .source_path = source_path, + .written_date = times->get(utils::file::time_type::written), + }; return file; } @@ -97,7 +100,7 @@ void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory, meta[META_UID] = std::to_string(buf.st_uid); #if defined(__APPLE__) - meta[META_BACKUP] = std::to_string(buf.st_bkuptime); + meta[META_BACKUP]; meta[META_OSXFLAGS] = std::to_string(buf.st_flags); #endif // defined(__APPLE__) } diff --git a/repertory/librepertory/src/providers/s3/s3_provider.cpp b/repertory/librepertory/src/providers/s3/s3_provider.cpp index 187ce69c..5198578e 100644 --- a/repertory/librepertory/src/providers/s3/s3_provider.cpp +++ b/repertory/librepertory/src/providers/s3/s3_provider.cpp @@ -404,7 +404,7 @@ auto s3_provider::get_directory_items_impl(const std::string &api_path, file.api_path = dir_item.api_path; file.api_parent = dir_item.api_parent; file.accessed_date = file.changed_date = file.creation_date = - file.modified_date = last_modified; + file.modified_date = file.written_date = last_modified; file.file_size = dir_item.size; if (is_encrypted) { file.key = child_object_name; @@ -540,7 +540,7 @@ auto s3_provider::get_file(const std::string &api_path, api_file &file) const file.api_path = api_path; file.api_parent = utils::path::get_parent_api_path(api_path); file.accessed_date = file.changed_date = file.creation_date = - file.modified_date = result.last_modified; + file.modified_date = file.written_date = result.last_modified; file.key = is_encrypted ? utils::path::create_api_path(object_name) : ""; file.file_size = is_encrypted @@ -616,21 +616,24 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const auto size{node.node().select_node("Size").node().text().as_ullong()}; - api_file file{}; - file.api_path = utils::path::create_api_path(api_path); - file.api_parent = utils::path::get_parent_api_path(file.api_path); - file.accessed_date = file.changed_date = file.creation_date = - file.modified_date = convert_api_date(node.node() - .select_node("LastModified") - .node() - .text() - .as_string()); - file.file_size = - is_encrypted - ? utils::encryption::encrypting_reader::calculate_decrypted_size( - size, not legacy_bucket_) - : size; - file.key = is_encrypted ? utils::path::create_api_path(object_name) : ""; + api_path = utils::path::create_api_path(api_path); + auto date = convert_api_date( + node.node().select_node("LastModified").node().text().as_string()); + api_file file{ + .api_path = api_path, + .api_parent = utils::path::get_parent_api_path(api_path), + .accessed_date = date, + .changed_date = date, + .creation_date = date, + .file_size = is_encrypted ? utils::encryption::encrypting_reader:: + calculate_decrypted_size( + size, not legacy_bucket_) + : size, + .key = is_encrypted ? utils::path::create_api_path(object_name) : "", + .modified_date = date, + .source_path = "", + .written_date = date, + }; auto res{add_if_not_found(file, file.key)}; if (res != api_error::success) { return res; diff --git a/repertory/librepertory/src/utils/windows/windows_utils.cpp b/repertory/librepertory/src/utils/windows/windows_utils.cpp index 6f533d62..21e89732 100644 --- a/repertory/librepertory/src/utils/windows/windows_utils.cpp +++ b/repertory/librepertory/src/utils/windows/windows_utils.cpp @@ -93,16 +93,21 @@ auto get_accessed_time_from_meta(const api_meta_map &meta) -> std::uint64_t { utils::string::to_uint64(meta.at(META_ACCESSED))); } -auto get_changed_time_from_meta(const api_meta_map &meta) -> std::uint64_t { - return utils::time::unix_time_to_windows_time( - utils::string::to_uint64(meta.at(META_MODIFIED))); -} - auto get_creation_time_from_meta(const api_meta_map &meta) -> std::uint64_t { return utils::time::unix_time_to_windows_time( utils::string::to_uint64(meta.at(META_CREATION))); } +auto get_changed_time_from_meta(const api_meta_map &meta) -> std::uint64_t { + return utils::time::unix_time_to_windows_time( + utils::string::to_uint64(meta.at(META_CHANGED))); +} + +auto get_modified_time_from_meta(const api_meta_map &meta) -> std::uint64_t { + return utils::time::unix_time_to_windows_time( + utils::string::to_uint64(meta.at(META_MODIFIED))); +} + auto get_written_time_from_meta(const api_meta_map &meta) -> std::uint64_t { return utils::time::unix_time_to_windows_time( utils::string::to_uint64(meta.at(META_WRITTEN))); @@ -119,7 +124,7 @@ auto unix_access_mask_to_windows(std::int32_t mask) -> int { return mask & 6; } -auto unix_open_flags_to_flags_and_perms(remote::file_mode /*mode*/, +auto unix_open_flags_to_flags_and_perms(remote::file_mode /*mode*/, const remote::open_flags &flags, std::int32_t &perms) -> int { auto ret = _O_BINARY | _O_RANDOM; diff --git a/repertory/repertory_test/include/fixtures/providers_fixture.hpp b/repertory/repertory_test/include/fixtures/providers_fixture.hpp index 82c9b763..2ca78e5f 100644 --- a/repertory/repertory_test/include/fixtures/providers_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/providers_fixture.hpp @@ -220,9 +220,9 @@ protected: static void create_directory(const std::string &api_path) { auto date = utils::time::get_time_now(); - auto meta = create_meta_attributes( - date, 1U, date + 1U, date + 2U, true, getgid(), "", 0700, date + 3U, 2U, - 3U, 0U, api_path + "_src", getuid(), date + 4U); + auto meta = create_meta_attributes(date, 1U, date + 1U, date + 2U, true, + getgid(), "", 0700, date + 3U, 2U, 0U, + api_path + "_src", getuid(), date + 4U); EXPECT_EQ(api_error::success, provider->create_directory(api_path, meta)); bool exists{}; @@ -241,8 +241,7 @@ protected: static_cast(utils::string::to_uint32(meta2[META_GID]))); EXPECT_EQ(std::uint32_t(0700), utils::string::to_uint32(meta2[META_MODE])); EXPECT_EQ(date + 3U, utils::string::to_uint64(meta2[META_MODIFIED])); - EXPECT_EQ(2U, utils::string::to_uint64(meta2[META_BACKUP])); - EXPECT_EQ(3U, utils::string::to_uint64(meta2[META_OSXFLAGS])); + EXPECT_EQ(2U, utils::string::to_uint64(meta2[META_OSXFLAGS])); EXPECT_FALSE(utils::string::to_bool(meta2[META_PINNED])); EXPECT_EQ(std::uint64_t(0U), utils::string::to_uint64(meta2[META_SIZE])); EXPECT_EQ(getuid(), @@ -255,8 +254,8 @@ protected: auto date = utils::time::get_time_now(); auto meta = create_meta_attributes(date, 1U, date + 1U, date + 2U, false, - getgid(), "", 0700, date + 3U, 2U, 3U, - 0U, source_path, getuid(), date + 4U); + getgid(), "", 0700, date + 3U, 2U, 0U, + source_path, getuid(), date + 4U); EXPECT_EQ(api_error::success, provider->create_file(api_path, meta)); bool exists{}; @@ -277,8 +276,7 @@ protected: static_cast(utils::string::to_uint32(meta2[META_GID]))); EXPECT_EQ(std::uint32_t(0700), utils::string::to_uint32(meta2[META_MODE])); EXPECT_EQ(date + 3U, utils::string::to_uint64(meta2[META_MODIFIED])); - EXPECT_EQ(2U, utils::string::to_uint64(meta2[META_BACKUP])); - EXPECT_EQ(3U, utils::string::to_uint64(meta2[META_OSXFLAGS])); + EXPECT_EQ(2U, utils::string::to_uint64(meta2[META_OSXFLAGS])); EXPECT_FALSE(utils::string::to_bool(meta2[META_PINNED])); EXPECT_EQ(std::uint64_t(0U), utils::string::to_uint64(meta2[META_SIZE])); EXPECT_STREQ(source_path.c_str(), meta2[META_SOURCE].c_str()); diff --git a/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp b/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp index 2aa19d75..8f649186 100644 --- a/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp +++ b/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp @@ -158,7 +158,8 @@ public: for (const auto &[key, value] : meta) { meta_[api_path][key] = value; } - }; + } +}; } // namespace repertory #endif // !defined(_WIN32) diff --git a/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp b/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp index 92b6ee87..b6604f32 100644 --- a/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp +++ b/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp @@ -60,7 +60,7 @@ public: {META_MODIFIED, std::to_string(utils::time::get_time_now())}, {META_WRITTEN, std::to_string(utils::time::get_time_now())}, {META_ACCESSED, std::to_string(utils::time::get_time_now())}, - {META_CREATION, std::to_string(utils::time::get_time_now())}}; + {META_CHANGED, std::to_string(utils::time::get_time_now())}}; list.emplace_back(di); di.api_path = ".."; diff --git a/repertory/repertory_test/src/file_manager_test.cpp b/repertory/repertory_test/src/file_manager_test.cpp index 0fc252e4..1569c63b 100644 --- a/repertory/repertory_test/src/file_manager_test.cpp +++ b/repertory/repertory_test/src/file_manager_test.cpp @@ -128,6 +128,7 @@ TEST_F(file_manager_test, can_start_and_stop) { TEST_F(file_manager_test, can_create_and_close_file) { cfg->set_enable_download_timeout(true); + cfg->set_download_timeout_secs(1U); EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(mp, get_pinned_files()) @@ -156,7 +157,7 @@ TEST_F(file_manager_test, can_create_and_close_file) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_ARCHIVE, now + 1U, now + 2U, false, 1, "key", 2, now + 3U, - 3U, 4U, 0U, source_path, 10U, now + 4U); + 0U, 0U, source_path, 10U, now + 4U); EXPECT_CALL(mp, create_file("/test_create.txt", meta)) .WillOnce(Return(api_error::success)); @@ -235,6 +236,7 @@ TEST_F(file_manager_test, can_create_and_close_file) { TEST_F(file_manager_test, can_open_and_close_file) { cfg->set_enable_download_timeout(true); + cfg->set_download_timeout_secs(1U); EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(mp, get_pinned_files()) @@ -261,7 +263,7 @@ TEST_F(file_manager_test, can_open_and_close_file) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_ARCHIVE, now + 1U, now + 2U, false, 1U, "key", 2U, now + 3U, - 3U, 4U, 0U, source_path, 10U, now + 4U); + 0U, 0U, source_path, 10U, now + 4U); EXPECT_CALL(mp, create_file).Times(0U); @@ -356,7 +358,7 @@ TEST_F(file_manager_test, can_open_and_close_multiple_handles_for_same_file) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_ARCHIVE, now + 1U, now + 2U, false, 1U, "key", 2U, now + 3U, - 3U, 4U, 0U, source_path, 10U, now + 4U); + 0U, 4U, source_path, 10U, now + 4U); EXPECT_CALL(mp, create_file).Times(0U); @@ -432,7 +434,7 @@ TEST_F(file_manager_test, auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_ARCHIVE, now + 1U, now + 2U, false, 1U, "key", 2U, - now + 3U, 3U, 4U, + now + 3U, 3U, utils::encryption::encrypting_reader::get_data_chunk_size() * 4U, source_path, 10U, now + 4U); auto &file = @@ -558,6 +560,7 @@ TEST_F(file_manager_test, TEST_F(file_manager_test, upload_occurs_after_write_if_fully_downloaded) { cfg->set_enable_download_timeout(true); + cfg->set_download_timeout_secs(1U); EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false)); EXPECT_CALL(mp, get_pinned_files()) @@ -586,8 +589,8 @@ TEST_F(file_manager_test, upload_occurs_after_write_if_fully_downloaded) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( - now, FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, - now + 3u, 3u, 4u, + now, FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2U, false, 1, "key", 2, + now + 3u, 3u, utils::encryption::encrypting_reader::get_data_chunk_size() * 4u, source_path, 10, now + 4u); auto &file = @@ -697,8 +700,8 @@ TEST_F(file_manager_test, can_evict_file) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_ARCHIVE, now + 1u, - now + 2u, false, 1, "key", 2, now + 3u, 3u, - 4u, 0u, source_path, 10, now + 4u); + now + 2U, false, 1, "key", 2, now + 3u, 3u, + 0U, source_path, 10, now + 4u); std::uint64_t handle{}; { std::shared_ptr open_file; @@ -890,8 +893,8 @@ TEST_F(file_manager_test, evict_file_fails_if_file_is_uploading) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_ARCHIVE, now + 1u, - now + 2u, false, 1, "", 2, now + 3u, 3u, - 4u, 0u, source_path, 10, now + 4u); + now + 2U, false, 1, "", 2, now + 3u, 3u, + 0U, source_path, 10, now + 4u); std::uint64_t handle{}; { std::shared_ptr open_file; @@ -1086,8 +1089,8 @@ TEST_F(file_manager_test, file_is_not_opened_if_provider_create_file_fails) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_ARCHIVE, now + 1u, - now + 2u, false, 1, "", 2, now + 3u, 3u, - 4u, 0u, "/test_create.src", 10, now + 4u); + now + 2U, false, 1, "", 2, now + 3u, 3u, + 0U, "/test_create.src", 10, now + 4u); file_manager mgr(*cfg, mp); EXPECT_CALL(mp, create_file("/test_create.txt", meta)) @@ -1421,6 +1424,7 @@ TEST_F(file_manager_test, can_remove_file) { .key = "", .modified_date = 0, .source_path = "", + .written_date = 0, }; EXPECT_CALL(mp, get_item_meta(_, _)) @@ -1478,7 +1482,7 @@ TEST_F(file_manager_test, can_queue_and_remove_upload) { TEST_F(file_manager_test, file_is_closed_after_download_timeout) { cfg->set_enable_download_timeout(true); - cfg->set_download_timeout_secs(3U); + cfg->set_download_timeout_secs(1U); polling::instance().start(cfg.get()); @@ -1499,8 +1503,8 @@ TEST_F(file_manager_test, file_is_closed_after_download_timeout) { auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( - now, FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, - now + 3u, 3u, 4u, + now, FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2U, false, 1, "key", 2, + now + 3u, 3u, utils::encryption::encrypting_reader::get_data_chunk_size() * 4u, source_path, 10, now + 4u); @@ -1657,7 +1661,7 @@ TEST_F(file_manager_test, auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_ARCHIVE, now + 1U, now + 2U, false, 1U, "key", 2, now + 3U, - 3U, 4U, 0U, source_path, 10U, now + 4U); + 0U, 0U, source_path, 10U, now + 4U); EXPECT_CALL(mp, create_file("/test_create.txt", meta)) .WillOnce(Return(api_error::success)); diff --git a/repertory/repertory_test/src/providers_test.cpp b/repertory/repertory_test/src/providers_test.cpp index a3a545d6..ff4f9a30 100644 --- a/repertory/repertory_test/src/providers_test.cpp +++ b/repertory/repertory_test/src/providers_test.cpp @@ -613,8 +613,6 @@ TYPED_TEST(providers_test, get_file) { file.accessed_date); EXPECT_LT(utils::time::get_time_now() - (utils::time::NANOS_PER_SECOND * 5U), file.changed_date); - EXPECT_LT(utils::time::get_time_now() - (utils::time::NANOS_PER_SECOND * 5U), - file.creation_date); EXPECT_LT(utils::time::get_time_now() - (utils::time::NANOS_PER_SECOND * 5U), file.modified_date); diff --git a/support/include/utils/types/file/i_fs_item.hpp b/support/include/utils/types/file/i_fs_item.hpp index 37724463..10b8e57b 100644 --- a/support/include/utils/types/file/i_fs_item.hpp +++ b/support/include/utils/types/file/i_fs_item.hpp @@ -30,6 +30,7 @@ namespace repertory::utils::file { enum class time_type { accessed, + changed, created, modified, written, @@ -37,6 +38,7 @@ enum class time_type { struct file_times final { std::uint64_t accessed{}; + std::uint64_t changed{}; std::uint64_t created{}; std::uint64_t modified{}; std::uint64_t written{}; @@ -47,6 +49,8 @@ struct file_times final { switch (type) { case time_type::accessed: return accessed; + case time_type::changed: + return changed; case time_type::created: return created; case time_type::modified: @@ -70,8 +74,8 @@ struct i_fs_item { [[nodiscard]] virtual auto copy_to(std::string_view to_path, bool overwrite) const -> bool = 0; - [[nodiscard]] virtual auto copy_to(std::wstring_view new_path, - bool overwrite) -> bool { + [[nodiscard]] virtual auto copy_to(std::wstring_view new_path, bool overwrite) + -> bool { return copy_to(utils::string::to_utf8(new_path), overwrite); } @@ -79,8 +83,8 @@ struct i_fs_item { [[nodiscard]] virtual auto get_path() const -> std::string = 0; - [[nodiscard]] virtual auto - get_time(time_type type) const -> std::optional; + [[nodiscard]] virtual auto get_time(time_type type) const + -> std::optional; [[nodiscard]] virtual auto is_directory_item() const -> bool = 0; diff --git a/support/src/utils/file.cpp b/support/src/utils/file.cpp index e16d674b..46107e72 100644 --- a/support/src/utils/file.cpp +++ b/support/src/utils/file.cpp @@ -209,7 +209,9 @@ auto get_times(std::string_view path) -> std::optional { if (res) { ret.accessed = utils::time::windows_file_time_to_unix_time(times.at(1U)); - ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U)); + ret.changed = utils::time::windows_file_time_to_unix_time(times.at(2U)); + ret.created = = + utils::time::windows_file_time_to_unix_time(times.at(0U)); ret.modified = utils::time::windows_file_time_to_unix_time(times.at(2U)); ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U)); @@ -228,6 +230,7 @@ auto get_times(std::string_view path) -> std::optional { } ret.accessed = utils::time::windows_time_t_to_unix_time(u_stat.st_atime); + ret.changed = utils::time::windows_time_t_to_unix_time(u_stat.st_ctime); ret.created = utils::time::windows_time_t_to_unix_time(u_stat.st_ctime); ret.modified = utils::time::windows_time_t_to_unix_time(u_stat.st_mtime); ret.written = utils::time::windows_time_t_to_unix_time(u_stat.st_mtime); @@ -246,7 +249,10 @@ auto get_times(std::string_view path) -> std::optional { ret.accessed = static_cast(u_stat.st_atimespec.tv_nsec) + static_cast(u_stat.st_atimespec.tv_sec) * utils::time::NANOS_PER_SECOND; - ret.created = static_cast(u_stat.st_ctimespec.tv_nsec) + + ret.created = static_cast(u_stat.st_birthtimespec.tv_nsec) + + static_cast(u_stat.st_birthtimespec.tv_sec) * + utils::time::NANOS_PER_SECOND; + ret.changed = static_cast(u_stat.st_ctimespec.tv_nsec) + static_cast(u_stat.st_ctimespec.tv_sec) * utils::time::NANOS_PER_SECOND; ret.modified = static_cast(u_stat.st_mtimespec.tv_nsec) + @@ -259,6 +265,9 @@ auto get_times(std::string_view path) -> std::optional { ret.accessed = static_cast(u_stat.st_atim.tv_nsec) + static_cast(u_stat.st_atim.tv_sec) * utils::time::NANOS_PER_SECOND; + ret.changed = static_cast(u_stat.st_ctim.tv_nsec) + + static_cast(u_stat.st_ctim.tv_sec) * + utils::time::NANOS_PER_SECOND; ret.created = static_cast(u_stat.st_ctim.tv_nsec) + static_cast(u_stat.st_ctim.tv_sec) * utils::time::NANOS_PER_SECOND; diff --git a/support/test/src/utils/encryption_read_encrypted_range_test.cpp b/support/test/src/utils/encryption_read_encrypted_range_test.cpp index 1536365f..6fd82a71 100644 --- a/support/test/src/utils/encryption_read_encrypted_range_test.cpp +++ b/support/test/src/utils/encryption_read_encrypted_range_test.cpp @@ -336,8 +336,6 @@ TEST_P(utils_encryption_read_encrypted_range_fixture, single_byte_read) { TEST_P(utils_encryption_read_encrypted_range_fixture, begin_at_exact_chunk_boundary) { - ASSERT_NE(chunk, 0U); - auto begin = static_cast(chunk); std::uint64_t end = begin + 1024U - 1U; if (end >= plain_sz) diff --git a/support/test/src/utils/file_test.cpp b/support/test/src/utils/file_test.cpp index a3748e9a..9fb195d8 100644 --- a/support/test/src/utils/file_test.cpp +++ b/support/test/src/utils/file_test.cpp @@ -510,6 +510,7 @@ TEST(utils_file, get_times) { utils::file::get_times(test::create_random_file(1U).get_path()); EXPECT_TRUE(times.has_value()); EXPECT_LT(0U, times->get(utils::file::time_type::accessed)); + EXPECT_LT(0U, times->get(utils::file::time_type::changed)); EXPECT_LT(0U, times->get(utils::file::time_type::created)); EXPECT_LT(0U, times->get(utils::file::time_type::modified)); EXPECT_LT(0U, times->get(utils::file::time_type::written)); @@ -520,6 +521,7 @@ TEST(utils_file, get_times) { utils::string::from_utf8(test::create_random_file(1U).get_path())); EXPECT_TRUE(times.has_value()); EXPECT_LT(0U, times->get(utils::file::time_type::accessed)); + EXPECT_LT(0U, times->get(utils::file::time_type::changed)); EXPECT_LT(0U, times->get(utils::file::time_type::created)); EXPECT_LT(0U, times->get(utils::file::time_type::modified)); EXPECT_LT(0U, times->get(utils::file::time_type::written)); @@ -540,6 +542,11 @@ TEST(utils_file, get_time) { EXPECT_TRUE(file_time.has_value()); EXPECT_LT(0U, file_time.value()); + file_time = + utils::file::get_time(file_path, utils::file::time_type::changed); + EXPECT_TRUE(file_time.has_value()); + EXPECT_LT(0U, file_time.value()); + file_time = utils::file::get_time(file_path, utils::file::time_type::created); EXPECT_TRUE(file_time.has_value()); @@ -565,6 +572,11 @@ TEST(utils_file, get_time) { EXPECT_TRUE(file_time.has_value()); EXPECT_LT(0U, file_time.value()); + file_time = + utils::file::get_time(file_path, utils::file::time_type::changed); + EXPECT_TRUE(file_time.has_value()); + EXPECT_LT(0U, file_time.value()); + file_time = utils::file::get_time(file_path, utils::file::time_type::created); EXPECT_TRUE(file_time.has_value());