This commit is contained in:
2024-08-23 17:38:52 -05:00
parent 8d12ef22b9
commit d810f287c2
2 changed files with 14 additions and 12 deletions

View File

@ -1310,20 +1310,21 @@ auto fuse_drive::utimens_impl(std::string api_path,
} }
meta.clear(); meta.clear();
const auto process_timespec = [&meta](auto *tv, const auto &val,
std::string attr) { const auto process_timespec = [&meta, &tv](const auto &src,
if ((tv == nullptr) || (val.tv_nsec == UTIME_NOW)) { std::string attr) {
if ((tv == nullptr) || (src.tv_nsec == UTIME_NOW)) {
meta[attr] = std::to_string(utils::time::get_time_now()); meta[attr] = std::to_string(utils::time::get_time_now());
} else if (val.tv_nsec != UTIME_OMIT) { } else if (src.tv_nsec != UTIME_OMIT) {
meta[attr] = std::to_string( meta[attr] = std::to_string(
val.tv_nsec + src.tv_nsec +
(val.tv_sec * static_cast<std::decay_t<decltype(val.tv_sec)>>( (src.tv_sec * static_cast<std::decay_t<decltype(src.tv_sec)>>(
utils::time::NANOS_PER_SECOND))); utils::time::NANOS_PER_SECOND)));
} }
}; };
process_timespec(tv, tv[0U], META_ACCESSED); process_timespec(tv[0U], META_ACCESSED);
process_timespec(tv, tv[1U], META_MODIFIED); process_timespec(tv[1U], META_MODIFIED);
if (not meta.empty()) { if (not meta.empty()) {
return provider_.set_item_meta(api_path, meta); return provider_.set_item_meta(api_path, meta);

View File

@ -26,6 +26,7 @@
#include "platform/platform.hpp" #include "platform/platform.hpp"
#include "providers/i_provider.hpp" #include "providers/i_provider.hpp"
#include "utils/common.hpp" #include "utils/common.hpp"
#include "utils/time.hpp"
namespace repertory { namespace repertory {
auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error { auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error {
@ -234,8 +235,8 @@ void fuse_drive_base::get_timespec_from_meta(const api_meta_map &meta,
const std::string &name, const std::string &name,
struct timespec &ts) { struct timespec &ts) {
const auto meta_time = utils::string::to_int64(meta.at(name)); const auto meta_time = utils::string::to_int64(meta.at(name));
ts.tv_nsec = meta_time % NANOS_PER_SECOND; ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
ts.tv_sec = meta_time / NANOS_PER_SECOND; ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
} }
auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t { auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t {
@ -342,8 +343,8 @@ void fuse_drive_base::set_timespec_from_meta(const api_meta_map &meta,
const std::string &name, const std::string &name,
struct timespec &ts) { struct timespec &ts) {
const auto meta_time = utils::string::to_int64(meta.at(name)); const auto meta_time = utils::string::to_int64(meta.at(name));
ts.tv_nsec = meta_time % NANOS_PER_SECOND; ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
ts.tv_sec = meta_time / NANOS_PER_SECOND; ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
} }
} // namespace repertory } // namespace repertory