From 1880c50fd801ba113b0176b7a01ef5dee53bf5bf Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 23 Apr 2025 10:27:53 -0500 Subject: [PATCH] refactor --- cmake/versions.cmake | 13 +++--- .../src/drives/fuse/fuse_drive.cpp | 2 +- .../src/drives/fuse/fuse_drive_base.cpp | 38 +++++++++------- .../fuse/remotefuse/remote_fuse_drive.cpp | 2 +- scripts/versions.sh | 1 - support/test/src/utils/file_test.cpp | 43 +++++++++++++++++-- web/repertory/lib/helpers.dart | 4 +- 7 files changed, 71 insertions(+), 32 deletions(-) diff --git a/cmake/versions.cmake b/cmake/versions.cmake index 07fb79c0..17d5eb4c 100644 --- a/cmake/versions.cmake +++ b/cmake/versions.cmake @@ -1,28 +1,27 @@ set(BINUTILS_VERSION 2.44) -set(BOOST2_MAJOR_VERSION 1) -set(BOOST2_MINOR_VERSION 76) -set(BOOST2_PATCH_VERSION 0) set(BOOST_MAJOR_VERSION 1) set(BOOST_MINOR_VERSION 88) set(BOOST_PATCH_VERSION 0) +set(BOOST2_MAJOR_VERSION 1) +set(BOOST2_MINOR_VERSION 76) +set(BOOST2_PATCH_VERSION 0) set(CPP_HTTPLIB_VERSION 0.20.0) -set(CURL2_VERSION 8_13_0) set(CURL_VERSION 8.13.0) -set(EXPAT2_VERSION 2_7_1) +set(CURL2_VERSION 8_13_0) set(EXPAT_VERSION 2.7.1) +set(EXPAT2_VERSION 2_7_1) set(GCC_VERSION 14.2.0) set(GTEST_VERSION 1.16.0) set(ICU_VERSION 76-1) set(JSON_VERSION 3.12.0) set(LIBSODIUM_VERSION 1.0.20) -set(MESA_VERSION 23.3.3) set(MINGW_VERSION 12.0.0) set(OPENSSL_VERSION 3.5.0) set(PKG_CONFIG_VERSION 0.29.2) set(PUGIXML_VERSION 1.15) set(ROCKSDB_VERSION 10.0.1) set(SPDLOG_VERSION 1.15.2) -set(SQLITE2_VERSION 3.49.1) set(SQLITE_VERSION 3490100) +set(SQLITE2_VERSION 3.49.1) set(STDUUID_VERSION 1.2.3) set(ZLIB_VERSION 1.3.1) diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index 6fd7ac03..a7ab2485 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -1445,4 +1445,4 @@ void fuse_drive::update_accessed_time(const std::string &api_path) { } } // namespace repertory -#endif // _WIN32 +#endif // !defined(_WIN32) diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp index 3a05d683..276af68b 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp @@ -35,8 +35,8 @@ auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error { return check_access(api_path, mask); } -auto fuse_drive_base::check_access(const std::string &api_path, - int mask) const -> api_error { +auto fuse_drive_base::check_access(const std::string &api_path, int mask) const + -> api_error { REPERTORY_USES_FUNCTION_NAME(); api_meta_map meta; @@ -137,8 +137,9 @@ auto fuse_drive_base::check_and_perform( return action(meta); } -auto fuse_drive_base::check_open_flags( - int flags, int mask, const api_error &fail_error) -> api_error { +auto fuse_drive_base::check_open_flags(int flags, int mask, + const api_error &fail_error) + -> api_error { return (((flags & mask) == 0) ? api_error::success : fail_error); } @@ -195,8 +196,8 @@ auto fuse_drive_base::check_parent_access(const std::string &api_path, return ret; } -auto fuse_drive_base::check_readable(int flags, - const api_error &fail_error) -> api_error { +auto fuse_drive_base::check_readable(int flags, const api_error &fail_error) + -> api_error { auto mode = (flags & O_ACCMODE); return ((mode == O_WRONLY) ? fail_error : api_error::success); } @@ -254,13 +255,16 @@ auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t { } #if defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters( - const char *name, const uint32_t &position, std::string &attribute_name, - const std::string &api_path) -> api_error { +auto fuse_drive_base::parse_xattr_parameters(const char *name, + const uint32_t &position, + std::string &attribute_name, + const std::string &api_path) + -> api_error { #else // !defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters( - const char *name, std::string &attribute_name, - const std::string &api_path) -> api_error { +auto fuse_drive_base::parse_xattr_parameters(const char *name, + std::string &attribute_name, + const std::string &api_path) + -> api_error { #endif // defined(__APPLE__) auto res = api_path.empty() ? api_error::bad_address : api_error::success; if (res != api_error::success) { @@ -293,9 +297,11 @@ auto fuse_drive_base::parse_xattr_parameters( std::string &attribute_name, const std::string &api_path) -> api_error { auto res = parse_xattr_parameters(name, position, attribute_name, api_path); #else // !defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters( - const char *name, const char *value, size_t size, - std::string &attribute_name, const std::string &api_path) -> api_error { +auto fuse_drive_base::parse_xattr_parameters(const char *name, + const char *value, size_t size, + std::string &attribute_name, + const std::string &api_path) + -> api_error { auto res = parse_xattr_parameters(name, attribute_name, api_path); #endif // defined(__APPLE__) if (res != api_error::success) { @@ -361,4 +367,4 @@ void fuse_drive_base::set_timespec_from_meta(const api_meta_map &meta, } } // namespace repertory -#endif // _WIN32 +#endif // !defined(_WIN32) diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp index 416c2a5a..9445fa28 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp @@ -604,4 +604,4 @@ auto remote_fuse_drive::write_impl(std::string api_path, const char *buffer, } } // namespace repertory::remote_fuse -#endif // _WIN32 +#endif // !defined(_WIN32) diff --git a/scripts/versions.sh b/scripts/versions.sh index f3866b99..2f30b7f5 100755 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -18,7 +18,6 @@ PROJECT_VERSIONS[GTEST]="1.16.0" PROJECT_VERSIONS[ICU]="76-1" PROJECT_VERSIONS[JSON]="3.12.0" PROJECT_VERSIONS[LIBSODIUM]="1.0.20" -PROJECT_VERSIONS[MESA]="23.3.3" PROJECT_VERSIONS[MINGW]="12.0.0" PROJECT_VERSIONS[OPENSSL]="3.5.0" PROJECT_VERSIONS[PKG_CONFIG]="0.29.2" diff --git a/support/test/src/utils/file_test.cpp b/support/test/src/utils/file_test.cpp index d31c6b70..c31fb194 100644 --- a/support/test/src/utils/file_test.cpp +++ b/support/test/src/utils/file_test.cpp @@ -29,8 +29,8 @@ constexpr const auto file_type_count{3U}; constexpr const auto file_type_count{2U}; #endif -[[nodiscard]] auto create_file(auto idx, auto path, - bool read_only = false) -> auto { +[[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); @@ -47,8 +47,8 @@ constexpr const auto file_type_count{2U}; } } -[[nodiscard]] auto open_file(auto idx, auto path, - bool read_only = false) -> auto { +[[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); @@ -370,6 +370,41 @@ TEST(utils_file, directory_exists_in_path) { } } +TEST(utils_file, directory_can_get_empty_directory_count) { + auto &test_dir = test::generate_test_directory(); + EXPECT_EQ(0U, test_dir.count()); + EXPECT_EQ(0U, test_dir.count(false)); +} + +TEST(utils_file, directory_can_get_empty_directory_count_recursively) { + auto &test_dir = test::generate_test_directory(); + EXPECT_EQ(0U, test_dir.count(true)); +} + +TEST(utils_file, directory_can_get_non_empty_directory_count) { + auto &test_dir = test::generate_test_directory(); + auto sub_dir = test_dir.create_directory("sub_dir"); + EXPECT_TRUE(sub_dir != nullptr); + if (sub_dir) { + sub_dir->create_directory("sub_dir"); + + EXPECT_EQ(1U, test_dir.count()); + EXPECT_EQ(1U, test_dir.count(false)); + } +} + +TEST(utils_file, directory_can_get_non_empty_directory_count_recursively) { + auto &test_dir = test::generate_test_directory(); + auto sub_dir = test_dir.create_directory("sub_dir"); + EXPECT_TRUE(sub_dir != nullptr); + if (sub_dir) { + sub_dir = sub_dir->create_directory("sub_dir"); + EXPECT_TRUE(sub_dir != nullptr); + } + + EXPECT_EQ(2U, test_dir.count(true)); +} + TEST(utils_file, file_exists_in_path) { auto &test_dir = test::generate_test_directory(); EXPECT_FALSE( diff --git a/web/repertory/lib/helpers.dart b/web/repertory/lib/helpers.dart index 1c7fe69c..fccfb4a9 100644 --- a/web/repertory/lib/helpers.dart +++ b/web/repertory/lib/helpers.dart @@ -153,9 +153,9 @@ String getBaseUri() { String? getSettingDescription(String settingPath) { switch (settingPath) { case 'ApiPassword': - return "HTTP basic authentication password"; + return "HTTP authentication password"; case 'ApiUser': - return "HTTP basic authentication user"; + return "HTTP authentication user"; case 'HostConfig.ApiPassword': return "RENTERD_API_PASSWORD"; default: