Compare commits
1 Commits
d6475a85d7
...
v2.1.0-rc-
Author | SHA1 | Date | |
---|---|---|---|
8dd46b8ad8 |
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
* Ability to choose between RocksDB and SQLite databases
|
* Ability to choose between RocksDB and SQLite databases
|
||||||
* Added direct reads and implemented download fallback
|
* Added direct reads and implemented download fallback
|
||||||
* Comprehensive WinFSP and FUSE unit tests, including remote testing
|
|
||||||
* Corrected file times on S3 and Sia providers
|
* Corrected file times on S3 and Sia providers
|
||||||
* Corrected handling of `chown()` and `chmod()`
|
* Corrected handling of `chown()` and `chmod()`
|
||||||
* Fixed erroneous download of chunks after resize
|
* Fixed erroneous download of chunks after resize
|
||||||
|
@ -81,8 +81,8 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
|
|||||||
struct fuse_file_info * /*file_info*/)
|
struct fuse_file_info * /*file_info*/)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
#else
|
#else
|
||||||
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
|
auto fuse_drive::chown_impl(std::string api_path, uid_t uid,
|
||||||
-> api_error {
|
gid_t gid) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
return check_and_perform(
|
return check_and_perform(
|
||||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||||
@ -481,8 +481,8 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st,
|
|||||||
struct fuse_file_info * /*file_info*/)
|
struct fuse_file_info * /*file_info*/)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
#else
|
#else
|
||||||
auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
|
auto fuse_drive::getattr_impl(std::string api_path,
|
||||||
-> api_error {
|
struct stat *unix_st) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
auto parent = utils::path::get_parent_api_path(api_path);
|
auto parent = utils::path::get_parent_api_path(api_path);
|
||||||
|
|
||||||
@ -565,8 +565,8 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime,
|
|||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
|
auto fuse_drive::init_impl(struct fuse_conn_info *conn,
|
||||||
-> void * {
|
struct fuse_config *cfg) -> void * {
|
||||||
#else
|
#else
|
||||||
void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
|
void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
|
||||||
#endif
|
#endif
|
||||||
@ -800,9 +800,8 @@ auto fuse_drive::release_impl(std::string /*api_path*/,
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive::releasedir_impl(std::string /*api_path*/,
|
auto fuse_drive::releasedir_impl(
|
||||||
struct fuse_file_info *file_info)
|
std::string /*api_path*/, struct fuse_file_info *file_info) -> api_error {
|
||||||
-> api_error {
|
|
||||||
auto iter = directory_cache_->get_directory(file_info->fh);
|
auto iter = directory_cache_->get_directory(file_info->fh);
|
||||||
if (iter == nullptr) {
|
if (iter == nullptr) {
|
||||||
return api_error::invalid_handle;
|
return api_error::invalid_handle;
|
||||||
@ -820,8 +819,8 @@ auto fuse_drive::rename_directory(const std::string &from_api_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive::rename_file(const std::string &from_api_path,
|
auto fuse_drive::rename_file(const std::string &from_api_path,
|
||||||
const std::string &to_api_path, bool overwrite)
|
const std::string &to_api_path,
|
||||||
-> int {
|
bool overwrite) -> int {
|
||||||
auto res = fm_->rename_file(from_api_path, to_api_path, overwrite);
|
auto res = fm_->rename_file(from_api_path, to_api_path, overwrite);
|
||||||
errno = std::abs(utils::from_api_error(res));
|
errno = std::abs(utils::from_api_error(res));
|
||||||
return (res == api_error::success) ? 0 : -1;
|
return (res == api_error::success) ? 0 : -1;
|
||||||
@ -831,8 +830,8 @@ auto fuse_drive::rename_file(const std::string &from_api_path,
|
|||||||
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path,
|
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path,
|
||||||
unsigned int /*flags*/) -> api_error {
|
unsigned int /*flags*/) -> api_error {
|
||||||
#else
|
#else
|
||||||
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path)
|
auto fuse_drive::rename_impl(std::string from_api_path,
|
||||||
-> api_error {
|
std::string to_api_path) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
auto res = check_parent_access(to_api_path, W_OK | X_OK);
|
auto res = check_parent_access(to_api_path, W_OK | X_OK);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
@ -946,15 +945,15 @@ auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
|
|||||||
}
|
}
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
|
auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
|
||||||
char *value, size_t size, int &attribute_size)
|
char *value, size_t size,
|
||||||
-> api_error {
|
int &attribute_size) -> api_error {
|
||||||
return getxattr_common(api_path, name, value, size, attribute_size, nullptr);
|
return getxattr_common(api_path, name, value, size, attribute_size, nullptr);
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
|
auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
|
||||||
int &required_size, bool &return_size)
|
int &required_size,
|
||||||
-> api_error {
|
bool &return_size) -> api_error {
|
||||||
auto check_size = (size == 0);
|
auto check_size = (size == 0);
|
||||||
|
|
||||||
auto res = check_parent_access(api_path, X_OK);
|
auto res = check_parent_access(api_path, X_OK);
|
||||||
@ -994,8 +993,8 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive::removexattr_impl(std::string api_path, const char *name)
|
auto fuse_drive::removexattr_impl(std::string api_path,
|
||||||
-> api_error {
|
const char *name) -> api_error {
|
||||||
std::string attribute_name;
|
std::string attribute_name;
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
auto res = parse_xattr_parameters(name, 0, attribute_name, api_path);
|
auto res = parse_xattr_parameters(name, 0, attribute_name, api_path);
|
||||||
@ -1023,8 +1022,8 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
|||||||
uint32_t position) -> api_error {
|
uint32_t position) -> api_error {
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
||||||
const char *value, size_t size, int flags)
|
const char *value, size_t size,
|
||||||
-> api_error {
|
int flags) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
std::string attribute_name;
|
std::string attribute_name;
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
@ -1102,8 +1101,8 @@ void fuse_drive::set_item_meta(const std::string &api_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
|
auto fuse_drive::setattr_x_impl(std::string api_path,
|
||||||
-> api_error {
|
struct setattr_x *attr) -> api_error {
|
||||||
bool exists{};
|
bool exists{};
|
||||||
auto res = provider_.is_file(api_path, exists);
|
auto res = provider_.is_file(api_path, exists);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
@ -1157,7 +1156,7 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
|
|||||||
ts[0].tv_sec = attr->acctime.tv_sec;
|
ts[0].tv_sec = attr->acctime.tv_sec;
|
||||||
ts[0].tv_nsec = attr->acctime.tv_nsec;
|
ts[0].tv_nsec = attr->acctime.tv_nsec;
|
||||||
} else {
|
} else {
|
||||||
struct timeval tv{};
|
struct timeval tv {};
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
ts[0].tv_sec = tv.tv_sec;
|
ts[0].tv_sec = tv.tv_sec;
|
||||||
ts[0].tv_nsec = tv.tv_usec * 1000;
|
ts[0].tv_nsec = tv.tv_usec * 1000;
|
||||||
@ -1202,9 +1201,8 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive::setbkuptime_impl(std::string api_path,
|
auto fuse_drive::setbkuptime_impl(
|
||||||
const struct timespec *bkuptime)
|
std::string api_path, const struct timespec *bkuptime) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return check_and_perform(
|
return check_and_perform(
|
||||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||||
auto nanos = bkuptime->tv_nsec +
|
auto nanos = bkuptime->tv_nsec +
|
||||||
@ -1240,8 +1238,8 @@ auto fuse_drive::setvolname_impl(const char * /*volname*/) -> api_error {
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf)
|
auto fuse_drive::statfs_x_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct statfs *stbuf) -> api_error {
|
||||||
if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) {
|
if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) {
|
||||||
return api_error::os_error;
|
return api_error::os_error;
|
||||||
}
|
}
|
||||||
@ -1266,8 +1264,8 @@ auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf)
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf)
|
auto fuse_drive::statfs_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct statvfs *stbuf) -> api_error {
|
||||||
if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) {
|
if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) {
|
||||||
return api_error::os_error;
|
return api_error::os_error;
|
||||||
}
|
}
|
||||||
@ -1317,6 +1315,10 @@ auto fuse_drive::truncate_impl(std::string api_path, off_t size) -> api_error {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (not fm_->get_open_file(handle, true, open_file)) {
|
||||||
|
return api_error::invalid_handle;
|
||||||
|
}
|
||||||
|
|
||||||
res = open_file->resize(static_cast<std::uint64_t>(size));
|
res = open_file->resize(static_cast<std::uint64_t>(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1347,8 +1349,8 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2],
|
|||||||
struct fuse_file_info * /*file_info*/)
|
struct fuse_file_info * /*file_info*/)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
#else
|
#else
|
||||||
auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2])
|
auto fuse_drive::utimens_impl(std::string api_path,
|
||||||
-> api_error {
|
const struct timespec tv[2]) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
api_meta_map meta;
|
api_meta_map meta;
|
||||||
auto res = provider_.get_item_meta(api_path, meta);
|
auto res = provider_.get_item_meta(api_path, meta);
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "utils/path.hpp"
|
||||||
#include "utils/polling.hpp"
|
#include "utils/polling.hpp"
|
||||||
#include "utils/time.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
file_manager::file_manager(app_config &config, i_provider &provider)
|
file_manager::file_manager(app_config &config, i_provider &provider)
|
||||||
@ -220,7 +219,7 @@ auto file_manager::get_open_file_by_handle(std::uint64_t handle) const
|
|||||||
-> std::shared_ptr<i_closeable_open_file> {
|
-> std::shared_ptr<i_closeable_open_file> {
|
||||||
auto file_iter =
|
auto file_iter =
|
||||||
std::find_if(open_file_lookup_.begin(), open_file_lookup_.end(),
|
std::find_if(open_file_lookup_.begin(), open_file_lookup_.end(),
|
||||||
[&handle](const auto &item) -> bool {
|
[&handle](auto &&item) -> bool {
|
||||||
return item.second->has_handle(handle);
|
return item.second->has_handle(handle);
|
||||||
});
|
});
|
||||||
return (file_iter == open_file_lookup_.end()) ? nullptr : file_iter->second;
|
return (file_iter == open_file_lookup_.end()) ? nullptr : file_iter->second;
|
||||||
@ -381,11 +380,10 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
|||||||
return open(api_path, directory, ofd, handle, file, nullptr);
|
return open(api_path, directory, ofd, handle, file, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto file_manager::open(const std::string &api_path, bool directory,
|
auto file_manager::open(
|
||||||
const open_file_data &ofd, std::uint64_t &handle,
|
const std::string &api_path, bool directory, const open_file_data &ofd,
|
||||||
std::shared_ptr<i_open_file> &file,
|
std::uint64_t &handle, std::shared_ptr<i_open_file> &file,
|
||||||
std::shared_ptr<i_closeable_open_file> closeable_file)
|
std::shared_ptr<i_closeable_open_file> closeable_file) -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto create_and_add_handle =
|
const auto create_and_add_handle =
|
||||||
@ -437,7 +435,7 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
|||||||
auto ring_size{ring_buffer_file_size / chunk_size};
|
auto ring_size{ring_buffer_file_size / chunk_size};
|
||||||
|
|
||||||
const auto get_download_type = [&](download_type type) -> download_type {
|
const auto get_download_type = [&](download_type type) -> download_type {
|
||||||
if (directory || fsi.size == 0U) {
|
if (directory || fsi.size == 0U || is_processing(api_path)) {
|
||||||
return download_type::default_;
|
return download_type::default_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,8 +747,8 @@ auto file_manager::rename_directory(const std::string &from_api_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto file_manager::rename_file(const std::string &from_api_path,
|
auto file_manager::rename_file(const std::string &from_api_path,
|
||||||
const std::string &to_api_path, bool overwrite)
|
const std::string &to_api_path,
|
||||||
-> api_error {
|
bool overwrite) -> api_error {
|
||||||
if (not provider_.is_rename_supported()) {
|
if (not provider_.is_rename_supported()) {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ auto from_api_error(const api_error &err) -> int {
|
|||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
case api_error::file_in_use:
|
case api_error::file_in_use:
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
case api_error::invalid_handle:
|
||||||
|
return -EBADF;
|
||||||
case api_error::invalid_operation:
|
case api_error::invalid_operation:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
case api_error::item_not_found:
|
case api_error::item_not_found:
|
||||||
|
Reference in New Issue
Block a user