v2.0.3-rc (#32)
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit

# Changelog

## v2.0.3-rc

### Issues

* \#28 \[bug\] Address slow directory responses in S3 mounts for deeply nested directories
* \#29 \[bug\] S3 error responses are not being logged
* \#30 \[bug\] Sia provider error responses are not logged
* \#31 \[bug\] S3 provider should limit max key size to 1024

### Changes from v2.0.2-rc

* Always use direct for read-only providers
* Fixed externally removed files not being processed during cleanup
* Fixed http headers not being added for requests
* Fixed incorrect `stat` values for remote mounts
* Fixed invalid directory nullptr error on remote mounts
* Fixed memory leak in event system
* Refactored application shutdown
* Refactored event system
* Updated build system to Alpine 3.21.0
* Updated build system to MinGW-w64 12.0.0
* Updated copyright to 2018-2025

Reviewed-on: #32
This commit is contained in:
2025-02-11 17:26:24 -06:00
parent 8dd46b8ad8
commit fa439c634f
380 changed files with 9644 additions and 4217 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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
@ -57,8 +57,10 @@ auto create_random_file(std::size_t size) -> utils::file::i_file & {
#if defined(PROJECT_ENABLE_LIBSODIUM)
randombytes_buf(buf.data(), buf.size());
#else // !defined(PROJECT_ENABLE_LIBSODIUM)
thread_local std::mt19937 gen(static_cast<unsigned long>(
std::time(nullptr) ^ std::random_device{}()));
thread_local std::mt19937 gen{
static_cast<std::uint_fast32_t>(std::time(nullptr)) ^
static_cast<std::uint_fast32_t>(std::random_device{}()),
};
std::uniform_int_distribution<std::uint8_t> dis(0U, 255U);
std::generate(buf.begin(), buf.end(), [&]() -> auto { return dis(gen); });
#endif // defined(PROJECT_ENABLE_LIBSODIUM)

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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
@ -23,6 +23,10 @@
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
namespace {
const auto get_stop_requested = []() -> bool { return false; };
} // namespace
namespace repertory {
TEST(utils_encrypting_reader, read_file_data) {
const auto token = std::string("moose");
@ -30,9 +34,8 @@ TEST(utils_encrypting_reader, read_file_data) {
8U * utils::encryption::encrypting_reader::get_data_chunk_size());
EXPECT_TRUE(source_file);
if (source_file) {
stop_type stop_requested{false};
utils::encryption::encrypting_reader reader(
"test.dat", source_file.get_path(), stop_requested, token);
"test.dat", source_file.get_path(), get_stop_requested, token);
for (std::uint8_t i = 0U; i < 8U; i++) {
data_buffer buffer(
@ -70,9 +73,8 @@ TEST(utils_encrypting_reader, read_file_data_in_multiple_chunks) {
8U * utils::encryption::encrypting_reader::get_data_chunk_size());
EXPECT_TRUE(source_file);
if (source_file) {
stop_type stop_requested{false};
utils::encryption::encrypting_reader reader(
"test.dat", source_file.get_path(), stop_requested, token);
"test.dat", source_file.get_path(), get_stop_requested, token);
for (std::uint8_t i = 0U; i < 8U; i += 2U) {
data_buffer buffer(
@ -118,9 +120,8 @@ TEST(utils_encrypting_reader, read_file_data_as_stream) {
8U * utils::encryption::encrypting_reader::get_data_chunk_size());
EXPECT_TRUE(source_file);
if (source_file) {
stop_type stop_requested{false};
utils::encryption::encrypting_reader reader(
"test.dat", source_file.get_path(), stop_requested, token);
"test.dat", source_file.get_path(), get_stop_requested, token);
auto io_stream = reader.create_iostream();
EXPECT_FALSE(io_stream->seekg(0, std::ios_base::end).fail());
EXPECT_TRUE(io_stream->good());
@ -171,9 +172,8 @@ TEST(utils_encrypting_reader, read_file_data_in_multiple_chunks_as_stream) {
8u * utils::encryption::encrypting_reader::get_data_chunk_size());
EXPECT_TRUE(source_file);
if (source_file) {
stop_type stop_requested{false};
utils::encryption::encrypting_reader reader(
"test.dat", source_file.get_path(), stop_requested, token);
"test.dat", source_file.get_path(), get_stop_requested, token);
auto io_stream = reader.create_iostream();
EXPECT_FALSE(io_stream->seekg(0, std::ios_base::end).fail());
EXPECT_TRUE(io_stream->good());

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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
@ -23,6 +23,10 @@
#if defined(PROJECT_ENABLE_LIBSODIUM)
namespace {
const auto get_stop_requested = []() -> bool { return false; };
} // namespace
namespace repertory {
static constexpr const std::string_view token{"moose"};
static constexpr const std::wstring_view token_w{L"moose"};
@ -250,9 +254,8 @@ TEST(utils_encryption, decrypt_file_name) {
8U * utils::encryption::encrypting_reader::get_data_chunk_size());
EXPECT_TRUE(source_file);
if (source_file) {
stop_type stop_requested{false};
utils::encryption::encrypting_reader reader(
"test.dat", source_file.get_path(), stop_requested, token,
"test.dat", source_file.get_path(), get_stop_requested, token,
std::nullopt);
auto file_name = reader.get_encrypted_file_name();
@ -267,9 +270,9 @@ TEST(utils_encryption, decrypt_file_path) {
8U * utils::encryption::encrypting_reader::get_data_chunk_size());
EXPECT_TRUE(source_file);
if (source_file) {
stop_type stop_requested{false};
utils::encryption::encrypting_reader reader(
"test.dat", source_file.get_path(), stop_requested, token, "moose/cow");
"test.dat", source_file.get_path(), get_stop_requested, token,
"moose/cow");
auto file_path = reader.get_encrypted_file_path();

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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
@ -22,9 +22,49 @@
#include "test.hpp"
namespace {
static constexpr const auto file_type_count{1U};
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
#include "utils/file_enc_file.hpp"
constexpr const auto file_type_count{3U};
#else
constexpr const auto file_type_count{2U};
#endif
[[nodiscard]] auto create_file(auto idx, auto path,
bool read_only = false) -> auto {
switch (idx) {
case 0U:
return repertory::utils::file::file::open_or_create_file(path, read_only);
case 1U:
return repertory::utils::file::thread_file::open_or_create_file(path,
read_only);
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
case 2U:
return repertory::utils::file::enc_file::attach_file(
repertory::utils::file::file::open_or_create_file(path, read_only));
#endif
default:
throw std::runtime_error("not supported");
}
}
[[nodiscard]] auto open_file(auto idx, auto path,
bool read_only = false) -> auto {
switch (idx) {
case 0U:
return repertory::utils::file::file::open_file(path, read_only);
case 1U:
return repertory::utils::file::thread_file::open_file(path, read_only);
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
case 2U:
return repertory::utils::file::enc_file::attach_file(
repertory::utils::file::file::open_file(path, read_only));
#endif
default:
throw std::runtime_error("not supported");
}
}
} // namespace
namespace repertory {
TEST(utils_file, can_create_and_remove_file) {
for (auto idx = 0U; idx < file_type_count; ++idx) {
@ -32,8 +72,7 @@ TEST(utils_file, can_create_and_remove_file) {
EXPECT_FALSE(utils::file::file(path).exists() ||
utils::file::directory(path).exists());
auto file = idx == 0U ? utils::file::file::open_or_create_file(path)
: utils::file::thread_file::open_or_create_file(path);
auto file{create_file(idx, path)};
EXPECT_TRUE(*file);
EXPECT_TRUE(utils::file::file(path).exists());
@ -51,15 +90,12 @@ TEST(utils_file, can_open_file) {
auto path = test::generate_test_file_name("utils_file");
{
auto file = idx == 0U
? utils::file::file::open_or_create_file(path)
: utils::file::thread_file::open_or_create_file(path);
auto file{create_file(idx, path)};
EXPECT_TRUE(*file);
}
{
auto file = idx == 0U ? utils::file::file::open_file(path)
: utils::file::thread_file::open_file(path);
auto file{create_file(idx, path)};
EXPECT_TRUE(*file);
}
}
@ -69,8 +105,7 @@ TEST(utils_file, open_file_fails_if_not_found) {
for (auto idx = 0U; idx < file_type_count; ++idx) {
auto path = test::generate_test_file_name("utils_file");
auto file = idx == 0U ? utils::file::file::open_file(path)
: utils::file::thread_file::open_file(path);
auto file{open_file(idx, path)};
EXPECT_FALSE(*file);
}
}
@ -79,9 +114,7 @@ TEST(utils_file, write_fails_for_read_only_file) {
for (auto idx = 0U; idx < file_type_count; ++idx) {
auto path = test::generate_test_file_name("utils_file");
auto file = idx == 0U
? utils::file::file::open_or_create_file(path, true)
: utils::file::thread_file::open_or_create_file(path, true);
auto file{create_file(idx, path, true)};
EXPECT_TRUE(utils::file::file(path).exists());
EXPECT_TRUE(*file);
std::size_t bytes_written{};
@ -188,8 +221,8 @@ TEST(utils_file, read_and_write_json_file_encrypted) {
#if defined(PROJECT_ENABLE_LIBDSM)
TEST(utils_file, smb_create_smb_path) {
auto path = "//server/share";
auto rel_path = "test/test.txt";
const auto *path = "//server/share";
const auto *rel_path = "test/test.txt";
auto smb_path = utils::file::smb_create_smb_path(path, rel_path);
EXPECT_STREQ("//server/share/test/test.txt", smb_path.c_str());
@ -207,7 +240,7 @@ TEST(utils_file, smb_create_smb_path) {
}
TEST(utils_file, smb_create_relative_path) {
auto path = "//server/share/test.txt";
const auto *path = "//server/share/test.txt";
auto rel_path = utils::file::smb_create_relative_path(path);
EXPECT_STREQ("\\test.txt", rel_path.c_str());
@ -225,7 +258,7 @@ TEST(utils_file, smb_create_relative_path) {
}
TEST(utils_file, smb_create_search_path) {
auto path = "//server/share";
const auto *path = "//server/share";
auto search_path = utils::file::smb_create_search_path(path);
EXPECT_STREQ("\\*", search_path.c_str());
@ -251,8 +284,8 @@ TEST(utils_file, smb_create_search_path) {
}
TEST(utils_file, smb_parent_is_same) {
auto path1 = "//server/share";
auto path2 = "//server/share";
const auto *path1 = "//server/share";
const auto *path2 = "//server/share";
EXPECT_TRUE(utils::file::smb_parent_is_same(path1, path2));
path1 = "//server/share/";
@ -269,8 +302,8 @@ TEST(utils_file, smb_parent_is_same) {
}
TEST(utils_file, smb_parent_is_not_same) {
auto path1 = "server/share";
auto path2 = "//server/share";
const auto *path1 = "server/share";
const auto *path2 = "//server/share";
EXPECT_FALSE(utils::file::smb_parent_is_same(path1, path2));
path1 = "server/share/";

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <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