This commit is contained in:
Scott E. Graves 2024-12-20 19:36:02 -06:00
parent c93e6abaa9
commit 07d7699ba7

View File

@ -29,22 +29,18 @@
#include "utils/collection.hpp"
#include "utils/encrypting_reader.hpp"
#include "utils/encryption.hpp"
#include "utils/error_utils.hpp"
#include "utils/file_utils.hpp"
#include "utils/path.hpp"
#include "utils/polling.hpp"
namespace {
const std::string file_table = "file";
} // namespace
namespace repertory {
encrypt_provider::encrypt_provider(app_config &config)
: config_(config), encrypt_config_(config.get_encrypt_config()) {}
auto encrypt_provider::create_api_file(const std::string &api_path,
bool directory,
const std::string &source_path)
-> api_file {
auto encrypt_provider::create_api_file(
const std::string &api_path, bool directory,
const std::string &source_path) -> api_file {
auto times = utils::file::get_times(source_path);
if (not times.has_value()) {
throw std::runtime_error("failed to get file times");
@ -70,10 +66,10 @@ auto encrypt_provider::create_api_file(const std::string &api_path,
void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory,
const api_file &file) {
#if defined(_WIN32)
struct _stat64 buf{};
struct _stat64 buf {};
_stat64(file.source_path.c_str(), &buf);
#else // !defined(_WIN32)
struct stat buf{};
struct stat buf {};
stat(file.source_path.c_str(), &buf);
#endif // defined(_WIN32)
@ -153,9 +149,8 @@ auto encrypt_provider::do_fs_operation(
return callback(cfg, source_path);
}
auto encrypt_provider::get_api_path_from_source(const std::string &source_path,
std::string &api_path) const
-> api_error {
auto encrypt_provider::get_api_path_from_source(
const std::string &source_path, std::string &api_path) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
try {
@ -194,9 +189,8 @@ auto encrypt_provider::get_directory_item_count(
return count;
}
auto encrypt_provider::get_directory_items(const std::string &api_path,
directory_item_list &list) const
-> api_error {
auto encrypt_provider::get_directory_items(
const std::string &api_path, directory_item_list &list) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
return do_fs_operation(
@ -324,9 +318,8 @@ auto encrypt_provider::get_file(const std::string &api_path,
return api_error::error;
}
auto encrypt_provider::get_file_list(api_file_list &list,
std::string & /* marker */) const
-> api_error {
auto encrypt_provider::get_file_list(
api_file_list &list, std::string & /* marker */) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
const auto &cfg = get_encrypt_config();
@ -349,9 +342,8 @@ auto encrypt_provider::get_file_list(api_file_list &list,
return api_error::error;
}
auto encrypt_provider::get_file_size(const std::string &api_path,
std::uint64_t &file_size) const
-> api_error {
auto encrypt_provider::get_file_size(
const std::string &api_path, std::uint64_t &file_size) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
try {
@ -372,10 +364,9 @@ auto encrypt_provider::get_file_size(const std::string &api_path,
return api_error::error;
}
auto encrypt_provider::get_filesystem_item(const std::string &api_path,
bool directory,
filesystem_item &fsi) const
-> api_error {
auto encrypt_provider::get_filesystem_item(
const std::string &api_path, bool directory,
filesystem_item &fsi) const -> api_error {
std::string source_path;
if (directory) {
auto result = db_->get_directory_source_path(api_path, source_path);
@ -426,10 +417,9 @@ auto encrypt_provider::get_filesystem_item_from_source_path(
return get_filesystem_item(api_path, false, fsi);
}
auto encrypt_provider::get_filesystem_item_and_file(const std::string &api_path,
api_file &file,
filesystem_item &fsi) const
-> api_error {
auto encrypt_provider::get_filesystem_item_and_file(
const std::string &api_path, api_file &file,
filesystem_item &fsi) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
try {
@ -554,8 +544,8 @@ auto encrypt_provider::is_directory(const std::string &api_path,
return api_error::error;
}
auto encrypt_provider::is_file(const std::string &api_path, bool &exists) const
-> api_error {
auto encrypt_provider::is_file(const std::string &api_path,
bool &exists) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
try {