2.0.0-rc (#9)
Some checks failed
BlockStorage/repertory_osx/pipeline/head This commit looks good
BlockStorage/repertory_windows/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head There was a failure building this commit
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
BlockStorage/repertory_osx_builds/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory_osx/pipeline/head This commit looks good
BlockStorage/repertory_windows/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head There was a failure building this commit
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
BlockStorage/repertory_osx_builds/pipeline/head There was a failure building this commit
### Issues * \#1 \[bug\] Unable to mount S3 due to 'item_not_found' exception * \#2 Require bucket name for S3 mounts * \#3 \[bug\] File size is not being updated in S3 mount * \#4 Upgrade to libfuse-3.x.x * \#5 Switch to renterd for Sia support * \#6 Switch to cpp-httplib to further reduce dependencies * \#7 Remove global_data and calculate used disk space per provider * \#8 Switch to libcurl for S3 mount support ### Changes from v1.x.x * Added read-only encrypt provider * Pass-through mount point that transparently encrypts source data using `XChaCha20-Poly1305` * Added S3 encryption support via `XChaCha20-Poly1305` * Added replay protection to remote mounts * Added support base64 writes in remote FUSE * Created static linked Linux binaries for `amd64` and `aarch64` using `musl-libc` * Removed legacy Sia renter support * Removed Skynet support * Fixed multiple remote mount WinFSP API issues on \*NIX servers * Implemented chunked read and write * Writes for non-cached files are performed in chunks of 8Mib * Removed `repertory-ui` support * Removed `FreeBSD` support * Switched to `libsodium` over `CryptoPP` * Switched to `XChaCha20-Poly1305` for remote mounts * Updated `GoogleTest` to v1.14.0 * Updated `JSON for Modern C++` to v3.11.2 * Updated `OpenSSL` to v1.1.1w * Updated `RocksDB` to v8.5.3 * Updated `WinFSP` to 2023 * Updated `boost` to v1.78.0 * Updated `cURL` to v8.3.0 * Updated `zlib` to v1.3 * Use `upload_manager` for all providers * Adds a delay to uploads to prevent excessive API calls * Supports re-upload after mount restart for incomplete uploads * NOTE: Uploads for all providers are full file (no resume support) * Multipart upload support is planned for S3 Reviewed-on: #9
This commit is contained in:
@ -1,106 +1,96 @@
|
||||
/*
|
||||
Copyright <2018-2022> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_UTILS_FILE_UTILS_HPP_
|
||||
#define INCLUDE_UTILS_FILE_UTILS_HPP_
|
||||
|
||||
#include "common.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/native_file.hpp"
|
||||
|
||||
namespace repertory::utils::file {
|
||||
// Prototypes
|
||||
api_error assign_and_get_native_file(filesystem_item &fi, native_file_ptr &nf);
|
||||
|
||||
std::uint64_t calculate_used_space(std::string path, const bool &recursive);
|
||||
[[nodiscard]] auto calculate_used_space(std::string path, bool recursive)
|
||||
-> std::uint64_t;
|
||||
|
||||
void change_to_process_directory();
|
||||
|
||||
bool copy_directory_recursively(std::string from_path, std::string to_path);
|
||||
[[nodiscard]] auto copy_directory_recursively(std::string from_path,
|
||||
std::string to_path) -> bool;
|
||||
|
||||
bool copy_file(std::string from_path, std::string to_path);
|
||||
[[nodiscard]] auto copy_file(std::string from_path, std::string to_path)
|
||||
-> bool;
|
||||
|
||||
bool create_full_directory_path(std::string path);
|
||||
[[nodiscard]] auto create_full_directory_path(std::string path) -> bool;
|
||||
|
||||
bool delete_directory(std::string path, const bool &recursive = false);
|
||||
[[nodiscard]] auto delete_directory(std::string path, bool recursive = false)
|
||||
-> bool;
|
||||
|
||||
bool delete_directory_recursively(std::string path);
|
||||
[[nodiscard]] auto delete_directory_recursively(std::string path) -> bool;
|
||||
|
||||
bool delete_file(std::string path);
|
||||
[[nodiscard]] auto delete_file(std::string path) -> bool;
|
||||
|
||||
std::string generate_sha256(const std::string &file_path);
|
||||
[[nodiscard]] auto generate_sha256(const std::string &file_path) -> std::string;
|
||||
|
||||
std::uint64_t get_available_drive_space(const std::string &path);
|
||||
[[nodiscard]] auto get_accessed_time(const std::string &path,
|
||||
std::uint64_t &accessed) -> bool;
|
||||
|
||||
std::deque<std::string> get_directory_files(std::string path, const bool &oldest_first,
|
||||
const bool &recursive = false);
|
||||
[[nodiscard]] auto get_directory_files(std::string path, bool oldest_first,
|
||||
bool recursive = false)
|
||||
-> std::deque<std::string>;
|
||||
|
||||
bool get_accessed_time(const std::string &path, std::uint64_t &accessed);
|
||||
[[nodiscard]] auto get_free_drive_space(const std::string &path)
|
||||
-> std::uint64_t;
|
||||
|
||||
bool get_file_size(std::string path, std::uint64_t &file_size);
|
||||
[[nodiscard]] auto get_total_drive_space(const std::string &path)
|
||||
-> std::uint64_t;
|
||||
|
||||
bool get_modified_time(const std::string &path, std::uint64_t &modified);
|
||||
[[nodiscard]] auto get_file_size(std::string path, std::uint64_t &file_size)
|
||||
-> bool;
|
||||
|
||||
#ifdef _WIN32
|
||||
static open_file_data get_read_write_open_flags() { return open_file_data{}; }
|
||||
#else // _WIN32
|
||||
static int get_read_write_open_flags() { return O_RDWR; }
|
||||
#endif // _WIN32
|
||||
[[nodiscard]] auto get_modified_time(const std::string &path,
|
||||
std::uint64_t &modified) -> bool;
|
||||
|
||||
bool is_directory(const std::string &path);
|
||||
[[nodiscard]] auto is_directory(const std::string &path) -> bool;
|
||||
|
||||
bool is_file(const std::string &path);
|
||||
[[nodiscard]] auto is_file(const std::string &path) -> bool;
|
||||
|
||||
bool is_modified_date_older_than(const std::string &path, const std::chrono::hours &hours);
|
||||
[[nodiscard]] auto is_modified_date_older_than(const std::string &path,
|
||||
const std::chrono::hours &hours)
|
||||
-> bool;
|
||||
|
||||
bool move_file(std::string from, std::string to);
|
||||
[[nodiscard]] auto move_file(std::string from, std::string to) -> bool;
|
||||
|
||||
std::vector<std::string> read_file_lines(const std::string &path);
|
||||
[[nodiscard]] auto read_file_lines(const std::string &path)
|
||||
-> std::vector<std::string>;
|
||||
|
||||
api_error read_from_source(filesystem_item &fi, const std::size_t &read_size,
|
||||
const std::uint64_t &read_offset, std::vector<char> &data);
|
||||
[[nodiscard]] auto read_json_file(const std::string &path, json &data) -> bool;
|
||||
|
||||
template <typename t1, typename t2>
|
||||
bool read_from_stream(t1 *input_file, t2 &buf, std::size_t to_read);
|
||||
[[nodiscard]] auto reset_modified_time(const std::string &path) -> bool;
|
||||
|
||||
bool read_json_file(const std::string &path, json &data);
|
||||
[[nodiscard]] auto retry_delete_directory(const std::string &dir) -> bool;
|
||||
|
||||
bool reset_modified_time(const std::string &path);
|
||||
[[nodiscard]] auto retry_delete_file(const std::string &file) -> bool;
|
||||
|
||||
api_error truncate_source(filesystem_item &fi, const std::uint64_t &size);
|
||||
|
||||
bool write_json_file(const std::string &path, const json &j);
|
||||
|
||||
api_error write_to_source(filesystem_item &fi, const std::uint64_t &write_offset,
|
||||
const std::vector<char> &data, std::size_t &bytes_written);
|
||||
|
||||
// template implementations
|
||||
template <typename t1, typename t2>
|
||||
bool read_from_stream(t1 *input_file, t2 &buf, std::size_t to_read) {
|
||||
std::size_t offset = 0u;
|
||||
do {
|
||||
input_file->read((char *)&buf[offset], to_read);
|
||||
to_read -= static_cast<std::size_t>(input_file->gcount());
|
||||
offset += static_cast<std::size_t>(input_file->gcount());
|
||||
} while (not input_file->fail() && (to_read > 0u));
|
||||
|
||||
return (to_read == 0u);
|
||||
}
|
||||
[[nodiscard]] auto write_json_file(const std::string &path, const json &j)
|
||||
-> bool;
|
||||
} // namespace repertory::utils::file
|
||||
|
||||
#endif // INCLUDE_UTILS_FILE_UTILS_HPP_
|
||||
|
Reference in New Issue
Block a user