Compare commits
2 Commits
bb8cbb49f5
...
35db1cd0c4
Author | SHA1 | Date | |
---|---|---|---|
35db1cd0c4 | |||
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,
|
||||
|
@ -117,12 +117,13 @@ auto fuse_drive_base::check_and_perform(
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = check_parent_access(api_path, parent_mask)) !=
|
||||
api_error::success) {
|
||||
ret = check_parent_access(api_path, parent_mask);
|
||||
if (ret != api_error::success) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = check_owner(meta)) != api_error::success) {
|
||||
ret = check_owner(meta);
|
||||
if (ret != api_error::success) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -131,7 +132,7 @@ auto fuse_drive_base::check_and_perform(
|
||||
|
||||
auto fuse_drive_base::check_open_flags(
|
||||
int flags, int mask, const api_error &fail_error) -> api_error {
|
||||
return ((flags & mask) ? fail_error : api_error::success);
|
||||
return (((flags & mask) == 0) ? api_error::success : fail_error);
|
||||
}
|
||||
|
||||
auto fuse_drive_base::check_owner(const std::string &api_path) const
|
||||
@ -195,17 +196,17 @@ auto fuse_drive_base::check_readable(int flags,
|
||||
|
||||
auto fuse_drive_base::check_writeable(int flags, const api_error &fail_error)
|
||||
-> api_error {
|
||||
return ((flags & O_ACCMODE) ? api_error::success : fail_error);
|
||||
return (((flags & O_ACCMODE) == 0) ? fail_error : api_error::success);
|
||||
}
|
||||
|
||||
auto fuse_drive_base::get_current_gid() const -> gid_t {
|
||||
auto *ctx = fuse_get_context();
|
||||
return ctx ? ctx->gid : getgid();
|
||||
return (ctx == nullptr) ? getgid() : ctx->gid;
|
||||
}
|
||||
|
||||
auto fuse_drive_base::get_current_uid() const -> uid_t {
|
||||
auto *ctx = fuse_get_context();
|
||||
return ctx ? ctx->uid : getuid();
|
||||
return (ctx == nullptr) ? getuid() : ctx->uid;
|
||||
}
|
||||
|
||||
auto fuse_drive_base::get_effective_gid() const -> gid_t {
|
||||
@ -235,8 +236,10 @@ void fuse_drive_base::get_timespec_from_meta(const api_meta_map &meta,
|
||||
const std::string &name,
|
||||
struct timespec &ts) {
|
||||
auto meta_time = utils::string::to_uint64(meta.at(name));
|
||||
ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
|
||||
ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
|
||||
ts.tv_nsec =
|
||||
static_cast<std::int64_t>(meta_time % utils::time::NANOS_PER_SECOND);
|
||||
ts.tv_sec =
|
||||
static_cast<std::int64_t>(meta_time / utils::time::NANOS_PER_SECOND);
|
||||
}
|
||||
|
||||
auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t {
|
||||
@ -257,7 +260,7 @@ auto fuse_drive_base::parse_xattr_parameters(
|
||||
return res;
|
||||
}
|
||||
|
||||
if (not name) {
|
||||
if (name == nullptr) {
|
||||
return api_error::bad_address;
|
||||
}
|
||||
|
||||
@ -292,8 +295,9 @@ auto fuse_drive_base::parse_xattr_parameters(
|
||||
return res;
|
||||
}
|
||||
|
||||
return (value ? api_error::success
|
||||
: (size ? api_error::bad_address : api_error::success));
|
||||
return (value == nullptr
|
||||
? ((size == 0U) ? api_error::success : api_error::bad_address)
|
||||
: api_error::success);
|
||||
}
|
||||
|
||||
void fuse_drive_base::populate_stat(const std::string &api_path,
|
||||
@ -343,8 +347,10 @@ void fuse_drive_base::set_timespec_from_meta(const api_meta_map &meta,
|
||||
const std::string &name,
|
||||
struct timespec &ts) {
|
||||
auto meta_time = utils::string::to_uint64(meta.at(name));
|
||||
ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
|
||||
ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
|
||||
ts.tv_nsec =
|
||||
static_cast<std::int64_t>(meta_time % utils::time::NANOS_PER_SECOND);
|
||||
ts.tv_sec =
|
||||
static_cast<std::int64_t>(meta_time / utils::time::NANOS_PER_SECOND);
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user