time fixes
This commit is contained in:
@@ -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)
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -262,6 +262,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 {
|
||||
|
@@ -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;
|
||||
|
@@ -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__)
|
||||
}
|
||||
|
@@ -207,17 +207,18 @@ 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 {
|
||||
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 {
|
||||
return {
|
||||
{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)},
|
||||
@@ -243,8 +244,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,
|
||||
|
@@ -189,17 +189,18 @@ 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 {
|
||||
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 {
|
||||
return {
|
||||
{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)},
|
||||
@@ -223,8 +224,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,
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
@@ -99,6 +103,7 @@ auto base_provider::create_api_file(std::string path, std::uint64_t size,
|
||||
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]);
|
||||
file.written_date = utils::string::to_uint64(meta[META_WRITTEN]);
|
||||
return file;
|
||||
}
|
||||
|
||||
|
@@ -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 =
|
||||
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);
|
||||
file.modified_date = times->get(utils::file::time_type::written);
|
||||
file.source_path = source_path;
|
||||
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__)
|
||||
}
|
||||
|
@@ -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(
|
||||
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;
|
||||
file.key = is_encrypted ? utils::path::create_api_path(object_name) : "";
|
||||
: 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;
|
||||
|
@@ -95,12 +95,12 @@ auto get_accessed_time_from_meta(const api_meta_map &meta) -> std::uint64_t {
|
||||
|
||||
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)));
|
||||
utils::string::to_uint64(meta.at(META_CHANGED)));
|
||||
}
|
||||
|
||||
auto get_creation_time_from_meta(const api_meta_map &meta) -> std::uint64_t {
|
||||
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_CREATION)));
|
||||
utils::string::to_uint64(meta.at(META_MODIFIED)));
|
||||
}
|
||||
|
||||
auto get_written_time_from_meta(const api_meta_map &meta) -> std::uint64_t {
|
||||
|
@@ -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, 3U,
|
||||
api_path + "_src", getuid(), date + 4U);
|
||||
EXPECT_EQ(api_error::success, provider->create_directory(api_path, meta));
|
||||
|
||||
bool exists{};
|
||||
@@ -256,7 +256,7 @@ 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);
|
||||
source_path, getuid(), date + 4U);
|
||||
EXPECT_EQ(api_error::success, provider->create_file(api_path, meta));
|
||||
|
||||
bool exists{};
|
||||
|
@@ -158,6 +158,7 @@ public:
|
||||
for (const auto &[key, value] : meta) {
|
||||
meta_[api_path][key] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
|
@@ -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 = "..";
|
||||
|
@@ -156,7 +156,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);
|
||||
3U, 4U, source_path, 10U, now + 4U);
|
||||
|
||||
EXPECT_CALL(mp, create_file("/test_create.txt", meta))
|
||||
.WillOnce(Return(api_error::success));
|
||||
@@ -261,7 +261,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);
|
||||
3U, 4U, source_path, 10U, now + 4U);
|
||||
|
||||
EXPECT_CALL(mp, create_file).Times(0U);
|
||||
|
||||
@@ -356,7 +356,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);
|
||||
3U, 4U, source_path, 10U, now + 4U);
|
||||
|
||||
EXPECT_CALL(mp, create_file).Times(0U);
|
||||
|
||||
@@ -432,7 +432,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 =
|
||||
@@ -586,8 +586,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 +697,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,
|
||||
4u, source_path, 10, now + 4u);
|
||||
std::uint64_t handle{};
|
||||
{
|
||||
std::shared_ptr<i_open_file> open_file;
|
||||
@@ -890,8 +890,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,
|
||||
4u, source_path, 10, now + 4u);
|
||||
std::uint64_t handle{};
|
||||
{
|
||||
std::shared_ptr<i_open_file> open_file;
|
||||
@@ -1086,8 +1086,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,
|
||||
4u, "/test_create.src", 10, now + 4u);
|
||||
file_manager mgr(*cfg, mp);
|
||||
|
||||
EXPECT_CALL(mp, create_file("/test_create.txt", meta))
|
||||
@@ -1421,6 +1421,7 @@ TEST_F(file_manager_test, can_remove_file) {
|
||||
.key = "",
|
||||
.modified_date = 0,
|
||||
.source_path = "",
|
||||
.written_date = 0,
|
||||
};
|
||||
|
||||
EXPECT_CALL(mp, get_item_meta(_, _))
|
||||
@@ -1499,8 +1500,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 +1658,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);
|
||||
3U, 4U, source_path, 10U, now + 4U);
|
||||
|
||||
EXPECT_CALL(mp, create_file("/test_create.txt", meta))
|
||||
.WillOnce(Return(api_error::success));
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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<std::uint64_t>;
|
||||
[[nodiscard]] virtual auto get_time(time_type type) const
|
||||
-> std::optional<std::uint64_t>;
|
||||
|
||||
[[nodiscard]] virtual auto is_directory_item() const -> bool = 0;
|
||||
|
||||
|
@@ -209,7 +209,9 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
|
||||
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<file_times> {
|
||||
}
|
||||
|
||||
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<file_times> {
|
||||
ret.accessed = static_cast<std::uint64_t>(u_stat.st_atimespec.tv_nsec) +
|
||||
static_cast<std::uint64_t>(u_stat.st_atimespec.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
ret.created = static_cast<std::uint64_t>(u_stat.st_ctimespec.tv_nsec) +
|
||||
ret.created = static_cast<std::uint64_t>(u_stat.st_birthtimespec.tv_nsec) +
|
||||
static_cast<std::uint64_t>(u_stat.st_birthtimespec.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
ret.changed = static_cast<std::uint64_t>(u_stat.st_ctimespec.tv_nsec) +
|
||||
static_cast<std::uint64_t>(u_stat.st_ctimespec.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
ret.modified = static_cast<std::uint64_t>(u_stat.st_mtimespec.tv_nsec) +
|
||||
@@ -259,6 +265,9 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
|
||||
ret.accessed = static_cast<std::uint64_t>(u_stat.st_atim.tv_nsec) +
|
||||
static_cast<std::uint64_t>(u_stat.st_atim.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
ret.changed = static_cast<std::uint64_t>(u_stat.st_ctim.tv_nsec) +
|
||||
static_cast<std::uint64_t>(u_stat.st_ctim.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
ret.created = static_cast<std::uint64_t>(u_stat.st_ctim.tv_nsec) +
|
||||
static_cast<std::uint64_t>(u_stat.st_ctim.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
|
@@ -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<std::uint64_t>(chunk);
|
||||
std::uint64_t end = begin + 1024U - 1U;
|
||||
if (end >= plain_sz)
|
||||
|
@@ -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());
|
||||
|
Reference in New Issue
Block a user