diff --git a/.cspell/words.txt b/.cspell/words.txt index 40be5f7a..05e23079 100644 --- a/.cspell/words.txt +++ b/.cspell/words.txt @@ -5,6 +5,7 @@ _sh_denyrd _sh_denyrw _spawnv aarch64 +abcdefgh advapi32 armv8 autogen @@ -16,9 +17,12 @@ boost_asio_has_std_string_view bugprone cflags chrono +clsid cmake_current_source_dir +cmdc coinit_apartmentthreaded comdlg32 +conin$ cppcoreguidelines cppdbg cppflags @@ -27,7 +31,9 @@ cpptrace cppvsdbg create_notraverse crypto_aead_xchacha20poly1305_ietf_npubbytes +cspan cstdint +curl_zstd curle_couldnt_resolve_host curlopt_aws_sigv4 cxxflags @@ -54,6 +60,7 @@ dcurl_staticlib dcurl_use_libpsl dcurl_use_libssh2 dcurl_zlib +dcurl_zstd ddebug decmult_gen_prec_bits decmult_window_size @@ -86,6 +93,7 @@ dspdlog_fmt_external dthreads_prefer_pthread_flag dunw_local_only duse_libidn2 +duse_nghttp2 duuid_build_tests dwith_benchmark dwith_gflags @@ -97,6 +105,9 @@ endforeach endfunction eventlib expect_streq +expect_strne +falloc_fl_keep_size +fallocate fallocate_impl fext fgetattr @@ -105,7 +116,10 @@ filebase flac_version flag_nopath flarge +folderid fontconfig_version +foob +fooba freetype2_version fsetattr_x fusermount @@ -118,11 +132,14 @@ gpath gtest_version has_setxattr hkey +hresult httpapi httplib +hwnd icudata icui18n icuuc +inproc iostreams iphlpapi ipstream @@ -146,8 +163,10 @@ libuuid libuuid_include_dirs libvlc linkflags +llabsll localappdata lpbyte +lpthread lptr lpwstr markdownlint @@ -158,11 +177,13 @@ msvcr120 msys2 mtune musl-libc +mwindows nana ncrypt nlohmann nlohmann_json nmakeprg +noappledouble nohup nominmax ntstatus @@ -171,21 +192,27 @@ nuspell_version oleaut32 openal_version openssldir +osascript +osxfuse pistream pkgconfig plarge_integer plex +posix println project_enable_fontconfig project_enable_gtkmm project_enable_libdsm project_enable_nana +project_macos_icns_name propgrid psecurity_descriptor +pthreads pugi pugixml_project puint32 pvoid +pwhash pwstr rdrw remote_winfsp @@ -193,13 +220,16 @@ renterd richtext rocksdb_library rpcrt4 +runas s_igid s_isvtx s_iuid sddl_revision_1 secp256k1 secur32 +see_mask_nocloseprocess sfml_project +shellexecuteinfoa shlwapi sigchld skynet @@ -207,11 +237,14 @@ source_subdir spdlog spdlog_project st_ctim +startf_useshowwindow +startupinfoa static-libgcc static-libstdc++ stbuf stduuid_project strequal +sw_shownoactivate ularge_integer uring url @@ -230,6 +263,7 @@ wextra wfloat wformat=2 winfsp +winfsp_drive winhttp wininet winspool diff --git a/.gitattributes b/.gitattributes index d3af6d38..fe912ccd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ -*.tgz filter=lfs diff=lfs merge=lfs -text +*.msi filter=lfs diff=lfs merge=lfs -text *.tar.gz filter=lfs diff=lfs merge=lfs -text *.tar.xz filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 9c41b048..e76ce09a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,16 @@ +.DS_Store .cache/ +.vs/ +Info.plist build*/ compile_commands.json cspell.json -.vs/ -support/Dockerfile -dist/ deps/ +dist/ +override.sh +repertory.iss scripts/cleanup.cmd scripts/cleanup.sh -version.rc +support/Dockerfile version.cpp -override.sh +version.rc diff --git a/.jenkins_builds b/.jenkins_builds index 6ea987fb..d013ddb5 100644 --- a/.jenkins_builds +++ b/.jenkins_builds @@ -5,57 +5,88 @@ pipeline { environment { DEVELOPER_PRIVATE_KEY = "/.ci/repertory/cert/developer.priv" - DEVELOPER_PUBLIC_KEY = "/.ci/repertory/cert/developer.pub" - PROJECT_TEST_CONFIG_DIR = "/.ci/repertory/test_config" + DEVELOPER_PUBLIC_KEY = "/.ci/repertory/cert/developer.pub" + PROJECT_TEST_CONFIG_DIR = "/.ci/repertory/test" } options { disableConcurrentBuilds() - retry(2) + skipDefaultCheckout() + timestamps() } stages { - stage('linux_x86_64') { + stage('Build • Test • Deliver') { agent any - - steps { - retry(2) { - sleep time: 5, unit: 'SECONDS' - sh 'scripts/make_unix.sh' + stages { + stage('Checkout') { + steps { + script { + int maxAttempts = 6 + int baseDelay = 10 + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + try { + checkout scm + break + } catch (err) { + if (attempt == maxAttempts) { throw err } + int waitSec = baseDelay * (1 << (attempt - 1)) + echo "Checkout failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..." + sleep time: waitSec, unit: 'SECONDS' + } + } + } + } } - } - } - stage('mingw64') { - agent any - - steps { - retry(2) { - sleep time: 5, unit: 'SECONDS' - sh 'scripts/make_win32.sh' + stage('linux_x86_64') { + steps { + script { retryWithBackoff(2, 5) { sh 'scripts/make_unix.sh' } } + } } - } - } - stage('linux_aarch64') { - agent any - - steps { - retry(2) { - sleep time: 5, unit: 'SECONDS' - sh 'scripts/make_unix.sh aarch64' + stage('mingw64') { + steps { + script { retryWithBackoff(2, 5) { sh 'scripts/make_win32.sh' } } + } } - } - } - stage('deliver') { - agent any + stage('linux_aarch64') { + steps { + script { retryWithBackoff(2, 5) { sh 'scripts/make_unix.sh aarch64' } } + } + } - steps { - sh 'scripts/deliver.sh /mnt/repertory "" "" "" "" 1 1' - sh 'scripts/deliver.sh /mnt/repertory "" aarch64' - sh 'scripts/deliver.sh /mnt/repertory' + stage('linux_x86_64_test') { + steps { + script { retryWithBackoff(2, 5) { sh 'scripts/run_tests.sh' } } + } + } + + stage('deliver') { + steps { + script { + retryWithBackoff(3, 10) { sh 'scripts/deliver.sh /mnt/repertory "" "" "" "" 1 1' } + retryWithBackoff(3, 10) { sh 'scripts/deliver.sh /mnt/repertory "" aarch64' } + retryWithBackoff(3, 10) { sh 'scripts/deliver.sh /mnt/repertory' } + } + } + } } } } } + +def retryWithBackoff(int maxAttempts, int baseDelaySeconds, Closure body) { + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + try { + body() + return + } catch (err) { + if (attempt == maxAttempts) { throw err } + int waitSec = baseDelaySeconds * (1 << (attempt - 1)) + echo "Step failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..." + sleep time: waitSec, unit: 'SECONDS' + } + } +} diff --git a/.jenkins_macos b/.jenkins_macos new file mode 100644 index 00000000..43047334 --- /dev/null +++ b/.jenkins_macos @@ -0,0 +1,79 @@ +#!groovy + +pipeline { + agent none + + environment { + DEVELOPER_PRIVATE_KEY = "${env.HOME}/.ci/repertory/cert/developer.priv" + DEVELOPER_PUBLIC_KEY = "${env.HOME}/.ci/repertory/cert/developer.pub" + PROJECT_TEST_CONFIG_DIR = "${env.HOME}/.ci/repertory/test" + } + + options { + disableConcurrentBuilds() + skipDefaultCheckout() + timestamps() + } + + stages { + stage('Build • Test • Deliver') { + agent any + stages { + stage('Checkout') { + steps { + script { + int maxAttempts = 6 + int baseDelay = 10 + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + try { + checkout scm + break + } catch (err) { + if (attempt == maxAttempts) { throw err } + int waitSec = baseDelay * (1 << (attempt - 1)) + echo "Checkout failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..." + sleep time: waitSec, unit: 'SECONDS' + } + } + } + } + } + + stage('darwin_aarch64') { + steps { script { retryWithBackoff(2, 5) { sh 'scripts/make_unix.sh aarch64' } } } + } + + stage('darwin_x86_64') { + steps { script { retryWithBackoff(2, 5) { sh 'scripts/make_unix.sh x86_64' } } } + } + + stage('darwin_aarch64_test') { + steps { script { retryWithBackoff(2, 5) { sh 'scripts/run_tests.sh aarch64' } } } + } + + stage('deliver') { + steps { + script { + retryWithBackoff(3, 10) { sh "scripts/deliver.sh ${env.HOME}/mnt/repertory '' aarch64" } + retryWithBackoff(3, 10) { sh "scripts/deliver.sh ${env.HOME}/mnt/repertory '' x86_64" } + } + } + } + } + } + } +} + +def retryWithBackoff(int maxAttempts, int baseDelaySeconds, Closure body) { + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + try { + body() + return + } catch (err) { + if (attempt == maxAttempts) { throw err } + int waitSec = baseDelaySeconds * (1 << (attempt - 1)) + echo "Step failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..." + sleep time: waitSec, unit: 'SECONDS' + } + } +} diff --git a/.jenkins_msys2 b/.jenkins_msys2 new file mode 100644 index 00000000..44cf0696 --- /dev/null +++ b/.jenkins_msys2 @@ -0,0 +1,68 @@ +#!groovy + +pipeline { + agent none + + environment { + PROJECT_TEST_CONFIG_DIR = "c:\\.ci\\repertory\\test" + } + + options { + disableConcurrentBuilds() + skipDefaultCheckout() + timestamps() + } + + stages { + stage('Build • Test') { + agent any + stages { + stage('Checkout') { + steps { + script { + int maxAttempts = 6 + int baseDelay = 10 + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + try { + checkout scm + break + } catch (err) { + if (attempt == maxAttempts) { throw err } + int waitSec = baseDelay * (1 << (attempt - 1)) + echo "Checkout failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..." + sleep time: waitSec, unit: 'SECONDS' + } + } + } + } + } + + stage('msys2') { + steps { + script { retryWithBackoff(2, 5) { bat 'scripts\\make_win32.cmd' } } + } + } + + // stage('msys2_test') { + // steps { + // script { retryWithBackoff(2, 5) { bat 'scripts\\run_tests.cmd' } } + // } + // } + } + } + } +} + +def retryWithBackoff(int maxAttempts, int baseDelaySeconds, Closure body) { + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + try { + body() + return + } catch (err) { + if (attempt == maxAttempts) { throw err } + int waitSec = baseDelaySeconds * (1 << (attempt - 1)) + echo "Step failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..." + sleep time: waitSec, unit: 'SECONDS' + } + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 0243d81b..e1d31327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,55 @@ # Changelog +## v2.1.0-rc + +### BREAKING CHANGES + +* Mount state has been moved into the configuration directory + * Unmount all active mounts prior to upgrade +* Remote mounts must be upgraded to v2.1.0+ to support new authentication scheme + * Protocol handshake added for DoS protection + +### Issues + +* \#12 [unit test] Complete all providers unit tests +* \#22 [unit test] Complete FUSE unit tests +* \#33 Complete initial v2.0 documentation +* \#34 Add macOS support +* \#38 Pinning a file should automatically initiate a download to cache +* \#51 [ui] UI console window should close after launch +* \#52 [ui] Add auto-mount on first launch functionality +* \#53 Create Windows installer +* \#54 Remove 'default' as initial bucket name for Sia +* \#58 Create macOS bundle for simplified installation +* \#59 [bug] [ui] UI is hanging after launching repertory mount in background +* \#60 Implement secure key via KDF for transparent data encryption/decryption +* \#61 [ui] UI theme should match repertory blue + +### Changes from v2.0.7-release + +* Added check version support to remote mounts +* Fixed directory item count bug on S3 provider +* Fixed handling of `FALLOC_FL_KEEP_SIZE` on Linux +* Fixed intermittent client hang on remote mount server disconnect +* Implemented POSIX-compliant `unlink()` with FUSE `hard_remove` + * Open handles remain valid after `unlink()` +* Refactored CLI messages and error handling to use common methods +* Enhanced remote mount client thread mapping + * Threads are now mapped 1-1 from client to server instead of being tied to a fixed-size thread pool + ## v2.0.7-release + ### Issues + * \#55 [bug] UI is unable to launch `repertory.exe` on Windows when absolute path contains spaces * \#57 [bug] Directory entries . and .. are incorrectly being reported as files in Linux remote mounts ## v2.0.6-release + ### Issues + * \#42 [bug] Remote mount directory listing on Windows connected to Linux is failing * \#43 [bug] Directories are not importing properly for Sia * \#44 [bug] Windows-to-Linux remote mount ignores `CREATE_NEW` diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a03a842..225ee213 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,10 @@ if(PROJECT_IS_ARM64) add_definitions(-DPROJECT_IS_ARM64) endif() +if(PROJECT_IS_DARWIN) + add_definitions(-DPROJECT_IS_DARWIN) +endif() + if(PROJECT_IS_MINGW) option(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES "Enable path sizes of 32767 characters on Windows" OFF) if(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES) @@ -115,6 +119,16 @@ if(PROJECT_BUILD) ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp @ONLY ) + + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.iss.in") + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.iss.in + ${PROJECT_DIST_DIR}/../${PROJECT_NAME}.iss + @ONLY + ) + endif() + + find_package(ICU REQUIRED COMPONENTS data i18n io uc) else() message(STATUS "-=[CMake Settings]=-") message(STATUS " C standard: ${CMAKE_C_STANDARD}") @@ -170,9 +184,12 @@ endif() -DPROJECT_INTERFACE=1 -DPROJECT_IS_ALPINE=${PROJECT_IS_ALPINE} -DPROJECT_IS_ARM64=${PROJECT_IS_ARM64} + -DPROJECT_IS_DARWIN=${PROJECT_IS_DARWIN} -DPROJECT_IS_MINGW=${PROJECT_IS_MINGW} -DPROJECT_IS_MINGW_UNIX=${PROJECT_IS_MINGW_UNIX} -DPROJECT_MAJOR_VERSION=${PROJECT_MAJOR_VERSION} + -DPROJECT_MACOS_BUNDLE_ID=${PROJECT_MACOS_BUNDLE_ID} + -DPROJECT_MACOS_ICNS_NAME=${PROJECT_MACOS_ICNS_NAME} -DPROJECT_MINOR_VERSION=${PROJECT_MINOR_VERSION} -DPROJECT_NAME=${PROJECT_NAME} -DPROJECT_RELEASE_ITER=${PROJECT_RELEASE_ITER} diff --git a/README.md b/README.md index e4ccd0ee..7567cffb 100644 --- a/README.md +++ b/README.md @@ -1,153 +1,347 @@ # Repertory -Repertory allows you to mount S3 and Sia via FUSE on Linux or via WinFSP -on Windows. +Repertory allows you to mount **S3** and **Sia** storage as local drives using: -## Contents +- **FUSE** (Linux/macOS) +- **WinFSP** (Windows) -1. [Details and Features](#details-and-features) -2. [Minimum Requirements](#minimum-requirements) - 1. [Supported Operating Systems](#supported-operating-systems) -3. [GUI](#gui) -4. [Usage](#usage) - 1. [Important Options](#important-options) - 2. [Sia](#sia) - * [Sia Initial Configuration](#sia-initial-configuration) - * [Sia Mounting](#sia-mounting) - * [Sia Configuration File](#sia-configuration-file) - 3. [S3](#s3) - * [S3 Initial Configuration](#s3-initial-configuration) - * [S3 Mounting](#s3-mounting) - * [S3 Configuration File](#s3-configuration-file) -5. [Data Directories](#data-directories) - 1. [Linux Directories](#linux-directories) - 2. [Windows Directories](#windows-directories) -6. [Remote Mounting](#remote-mounting) - 1. [Server Setup](#server-setup) - * [Remote Mount Configuration File Section](#remote-mount-configuration-file-section) - 2. [Client Setup](#client-setup) - * [Client Remote Mounting](#client-remote-mounting) - * [Remote Mount Configuration File](#remote-mount-configuration-file) -7. [Compiling](#compiling) - 1. [Linux Compilation](#linux-compilation) - 2. [Windows Setup](#windows-compilation) -8. [Credits](#credits) -9. [Developer Public Key](#developer-public-key) -10. [Consult the Wiki for additional information](https://git.fifthgrid.com/BlockStorage/repertory/wiki) +It supports: -## Details and Features +- Local mounts +- Remote encrypted mounts between systems +- Optional file name and data encryption using `XChaCha20-Poly1305` and `Argon2id` for key generation -* Optimized for [Plex Media Server](https://www.plex.tv/) -* Remote mounting of `repertory` instances on Linux and Windows - * Securely share your mounts over TCP/IP via `XChaCha20-Poly1305` with other systems on your network or over the internet. -* Cross-platform support (Linux 64-bit, Linux arm64/aarch64, Windows 64-bit) -* Optionally encrypt file names and file data via `XChaCha20-Poly1305` in S3 mounts +--- -## Minimum Requirements +## 📖 Contents -* [Sia renterd](https://github.com/SiaFoundation/renterd/releases) v2.0.0+ for Sia support -* Linux requires `fusermount3`; otherwise, `repertory` must be manually compiled with `libfuse2` support -* Windows requires the following dependencies to be installed: - * [WinFSP 2025](https://github.com/winfsp/winfsp/releases/download/v2.1/winfsp-2.1.25156.msi) +1. [Quick Start (Sia Example)](#-quick-start-sia-example) +2. [Details & Features](#-details-and-features) +3. [Minimum Requirements](#-minimum-requirements) + - [Supported Operating Systems](#supported-operating-systems) +4. [Data Directories](#-data-directories) +5. [GUI](#-gui) +6. [Usage](#-usage) + - [Important Options](#important-options) + - [Unmounting](#unmounting) +7. [Sia Setup](#-sia) + - [Sia Initial Configuration](#sia-initial-configuration) + - [Sia Mounting](#sia-mounting) + - [Sia Configuration File](#sia-configuration-file) +8. [S3 Setup](#-s3) + - [S3 Initial Configuration](#s3-initial-configuration) + - [S3 Mounting](#s3-mounting) + - [S3 Configuration File](#s3-configuration-file) +9. [Remote Mounting](#-remote-mounting) + - [Server Setup](#server-setup) + - [Client Setup](#client-setup) + - [Remote Mount Configuration File](#remote-mount-configuration-file) +10. [Compiling from Source](#-compiling) + - [Linux Compilation](#linux-compilation) + - [macOS Compilation](#macos-compilation) + - [Windows Compilation](#windows-compilation) +11. [Credits](#-credits) +12. [Developer Public Key](#-developer-public-key) +13. [Consult the Wiki for additional information](https://git.fifthgrid.com/BlockStorage/repertory/wiki) + +--- + +## 🚀 Quick Start (Sia Example) + +> 💡 Want to mount S3 instead? +> Skip ahead to [S3 Setup](#-s3) — the process is almost identical. + +This example mounts a Sia bucket from a running [renterd](https://github.com/SiaFoundation/renterd) instance. + +--- + +### 1. Install dependencies + +#### Linux + +``` shell +sudo apt install fuse3 # Debian/Ubuntu +# or +sudo dnf install fuse3 # Fedora +``` + +#### macOS + +- Install [macFUSE 4.10.2](https://github.com/macfuse/macfuse/releases/download/macfuse-4.10.2/macfuse-4.10.2.dmg) + +#### Windows + +- Install [WinFSP 2025](https://github.com/winfsp/winfsp/releases/download/v2.1/winfsp-2.1.25156.msi) + +--- + +### 2. Configure + +Replace placeholders with your actual values: + +``` shell +repertory --name mybucket -set HostConfig.ApiPassword "" +repertory --name mybucket -set SiaConfig.Bucket "" +``` + +Optional: + +``` shell +# If renterd is not running locally +repertory --name mybucket -set HostConfig.HostNameOrIp "" + +# If renterd uses a non-default port (default 9980) +repertory --name mybucket -set HostConfig.ApiPort +``` + +--- + +### 3. Mount + + +#### Linux + +``` shell +repertory --name mybucket /mnt/mybucket +``` + + +#### macOS + +``` shell +repertory --name mybucket /Volumes/mybucket +``` + + +#### Windows + +``` shell +repertory --name mybucket t: +``` + +--- + +### 4. Unmount + +``` shell +repertory --name mybucket --unmount +``` + +--- + +## ✨ Details and Features + +- **Optimized for [Plex Media Server](https://www.plex.tv/).** +- Remote mounting of `repertory` instances between Linux, macOS, and/or Windows. + - Securely share your mounts over TCP/IP via `XChaCha20-Poly1305` with other systems on your network or over the internet. +- Cross-platform support (Linux, macOS, and Windows). +- Optionally encrypt file names and file data via `XChaCha20-Poly1305` in S3 mounts. + +--- + +## 📋 Minimum Requirements + +- **Sia:** [renterd](https://github.com/SiaFoundation/renterd/releases) v2.0.0+ for Sia support +- **Linux:** requires `fusermount3`; otherwise, `repertory` must be manually compiled with `libfuse2` support +- **macOS:** requires: + - [macFUSE 4.10.2](https://github.com/macfuse/macfuse/releases/download/macfuse-4.10.2/macfuse-4.10.2.dmg) +- **Windows:** requires: + - [WinFSP 2025](https://github.com/winfsp/winfsp/releases/download/v2.1/winfsp-2.1.25156.msi) ### Supported Operating Systems -Only 64-bit operating systems are supported +Only **64-bit operating systems** are supported: -* Linux `arm64/aarch64` -* Linux `amd64` -* Windows 64-bit 10, 11 +- Linux `arm64/aarch64` +- Linux `x86_64` +- macOS `arm64/aarch64` +- macOS `x86_64` +- Windows `x86_64` 10, 11 -## GUI +--- -As of `v2.0.5-rc`, mounts can be managed using the `Repertory Management Portal`. -To launch the portal, execute the following command: +## 📂 Data Directories -* `repertory -ui` - * The default username is `repertory` - * The default password is `repertory` + +### Linux -After first launch, `ui.json` will be created in the appropriate data directory. -See [Data Directories](#data-directories). -You should modify this file directly or use the portal to change the default -username and password. +``` shell +~/.local/repertory2/s3 +~/.local/repertory2/sia +``` -### Screenshot - -repertory-portal + +### Windows -## Usage +``` shell +%LOCALAPPDATA%\repertory2\s3 +%LOCALAPPDATA%\repertory2\sia +``` + +**IMPORTANT:** +It is highly recommended to **exclude** these folders from any anti-virus/anti-malware applications as severe performance issues may arise. Excluding the mounted drive letter is also highly recommended. + +--- + +## 🖥 GUI + +As of `v2.0.6-release`, mounts can be managed using the **Repertory Management Portal**. + +Launch the portal: + +``` shell +repertory -ui +``` + +### ⚠️ Security tip + +- Change the default UI credentials on first launch (`ui.json`) or via the portal +- Default username: `repertory` +- Default password: `repertory` + +After first launch, `ui.json` will be created in the appropriate data directory (see [Data Directories](#-data-directories)). Modify this file directly or use the portal to change the default credentials. + +### Screenshots + +#### Login screen + +![alt text](assets/login.png) + +#### Home screen + +![alt text](assets/home.png) + +--- + +## 🛠 Usage ### Important Options -* `--help` - * Display all mount utility options +- `--help` + Display all mount utility options. -* `-f` - * Keep process in foreground on Linux. +- `-f` + Keep process in foreground on Linux. -* `--name, -na [name]` - * Identifies a unique configuration name to support multiple mounts. - * The `--name` option can be set to any valid value allowed as a file name for your filesystem. - * For Sia, the bucket name will be set to the same value if it is empty in the configuration file. - * If the `--name` option is not specified, `default` will be used. - * For S3, the `--name` option is required and does not affect the bucket name. +- `--name, -na [name]` + Identifies a unique configuration name to support multiple mounts. + The `--name` option can be set to any valid value allowed as a file name for your filesystem. + **The `--name` option is required.** -* `-dc` - * Display mount configuration - * For Sia, `--name` is optional - * For S3, the `-s3` option is required along with `--name` +- `-dc` + Display mount configuration. + For Sia, the `--name` option is required. + For S3, the `-s3` and `--name` options are required. -### Sia +### Unmounting -#### Sia Initial Configuration +#### Remote -* Required steps: - * Set the appropriate bucket name and `renterd` API password in `repertory` configuration: - * To use `default` as the bucket name and configuration name, you only need to set the `renterd` API password: - * `repertory -set HostConfig.ApiPassword ''` - * To specify a different bucket name while using `default` as the configuration name: - * `repertory -set HostConfig.ApiPassword ''` - * `repertory -set SiaConfig.Bucket ''` - * For all other configurations: - * `repertory --name '' -set HostConfig.ApiPassword ''` - * `repertory --name '' -set SiaConfig.Bucket ''` +``` shell +repertory -rm 192.168.0.1:20000 --unmount +``` -* Optional steps: - * Set a user name used during `renterd` basic authentication: - * `repertory -set HostConfig.ApiUser ''` - * `repertory --name '' -set HostConfig.ApiUser ''` - * Set a custom agent string (default `Sia-Agent`): - * `repertory -set HostConfig.AgentString ''` - * `repertory --name '' -set HostConfig.AgentString ''` - * Set the host name or IP of the `renterd` instance (default `localhost`): - * `repertory -set HostConfig.HostNameOrIp ''` - * `repertory --name '' -set HostConfig.HostNameOrIp ''` - * Set the `renterd` API port (default `9980`): - * `repertory -set HostConfig.ApiPort 9981` - * `repertory --name '' -set HostConfig.ApiPort 9981` +#### S3 -* To verify/view all configuration options: - * `repertory -dc` - * `repertory --name '' -dc` - * Example: - * `repertory --name default -dc` +``` shell +repertory -s3 --name '' --unmount +``` -#### Sia Mounting +#### Sia -* Linux: - * `repertory /mnt/location` - * `repertory --name '' /mnt/location` - * Example: - * `repertory --name default /mnt/location` +``` shell +repertory --name '' --unmount +``` -* Windows: - * `repertory t:` - * `repertory --name '' t:` - * Example: - * `repertory --name default t:` +--- -#### Sia Configuration File +## 🔒 Security Best Practices + +When enabling **encryption tokens** for S3 or remote mounts: + +- Use a **long, random string**. +- Store it **offline** (password manager and an offline backup). +- Losing it means **permanent data loss**. + +--- + +## ☁️ Sia + +### Sia Initial Configuration + +**Required steps:** + +- Set the appropriate bucket name and `renterd` API password in `repertory` configuration: + +``` shell +repertory --name '' -set HostConfig.ApiPassword '' +repertory --name '' -set SiaConfig.Bucket '' +``` + +**Optional steps:** + +- Set a user name used during `renterd` basic authentication: + +``` shell +repertory --name '' -set HostConfig.ApiUser '' +``` + +- Set a custom agent string (default `Sia-Agent`): + +``` shell +repertory --name '' -set HostConfig.AgentString '' +``` + +- Set the host name or IP of the `renterd` instance (default `localhost`): + +``` shell +repertory --name '' -set HostConfig.HostNameOrIp '' +``` + +- Set the `renterd` API port (default `9980`): + +``` shell +repertory --name '' -set HostConfig.ApiPort 9981 +``` + +**Verify/view all configuration options:** + +``` shell +repertory --name '' -dc +# Example: +repertory --name my_bucket -dc +``` + +### Sia Mounting + + +#### Linux + +``` shell +repertory --name '' /mnt/location +# Example: +repertory --name my_bucket /mnt/location +``` + + +#### macOS + +``` shell +repertory --name '' /Volumes/mybucket +# Example: +repertory --name my_bucket /Volumes/mybucket +``` + + +#### Windows + +``` shell +repertory --name '' t: +# Example: +repertory --name my_bucket t: +``` + +### Sia Configuration File ```json { @@ -187,55 +381,105 @@ username and password. "RetryReadCount": 6, "RingBufferFileSize": 512, "SiaConfig": { - "Bucket": "default" + "Bucket": "my_bucket" }, "TaskWaitMs": 100, "Version": 1 } ``` -### S3 +--- -#### S3 Initial Configuration +## 🪣 S3 -* Required steps: - * Set the appropriate base URL: - * `repertory -s3 --name '' -set S3Config.URL ''` - * Example: - * `repertory -s3 --name minio -set S3Config.URL 'http://localhost:9000'` - * Set the appropriate bucket name: - * `repertory -s3 --name '' -set S3Config.Bucket ''` - * Set the appropriate access key: - * `repertory -s3 --name '' -set S3Config.AccessKey ''` - * Set the appropriate secret key: - * `repertory -s3 --name '' -set S3Config.SecretKey ''` - * For Sia and most local S3 gateway instances, enable path style URL's: - * `repertory -s3 --name '' -set S3Config.UsePathStyle true` +### S3 Initial Configuration -* Optional steps: - * Set an appropriate region. Default is set to `any`: - * `repertory -s3 --name '' -set S3Config.Region ''` - * Enable encrypted file names and file data. Set a strong, random encryption token and be sure to store it in a secure backup location: - * `repertory -s3 --name '' -set S3Config.EncryptionToken ''` +**Required steps:** -* To verify/view all configuration options: - * `repertory -s3 --name '' -dc` - * Example: - * `repertory -s3 --name minio -dc` +- Set the appropriate base URL: -#### S3 Mounting +``` shell +repertory -s3 --name '' -set S3Config.URL '' +# Example: +repertory -s3 --name minio -set S3Config.URL 'http://localhost:9000' +``` -* Linux: - * `repertory -s3 --name '' /mnt/location` - * Example: - * `repertory -s3 --name minio /mnt/location` +- Set the appropriate bucket name: -* Windows: - * `repertory -s3 --name '' t:` - * Example: - * `repertory -s3 --name minio t:` +``` shell +repertory -s3 --name '' -set S3Config.Bucket '' +``` -#### S3 Configuration File +- Set the appropriate access key: + +``` shell +repertory -s3 --name '' -set S3Config.AccessKey '' +``` + +- Set the appropriate secret key: + +``` shell +repertory -s3 --name '' -set S3Config.SecretKey '' +``` + +- For Sia and most local S3 gateway instances, enable path style URLs: + +``` shell +repertory -s3 --name '' -set S3Config.UsePathStyle true +``` + +**Optional steps:** + +- Set an appropriate region. Default is `any`: + +``` shell +repertory -s3 --name '' -set S3Config.Region '' +``` + +- Enable encrypted file names and file data. Set a strong, random encryption token and store it securely: + +``` shell +repertory -s3 --name '' -set S3Config.EncryptionToken '' +``` + +**Verify/view all configuration options:** + +``` shell +repertory -s3 --name '' -dc +# Example: +repertory -s3 --name minio -dc +``` + +### S3 Mounting + + +#### Linux + +``` shell +repertory -s3 --name '' /mnt/location +# Example: +repertory -s3 --name minio /mnt/location +``` + + +#### macOS + +``` shell +repertory -s3 --name '' /Volumes/minio +# Example: +repertory -s3 --name minio /Volumes/minio +``` + + +#### Windows + +``` shell +repertory -s3 --name '' t: +# Example: +repertory -s3 --name minio t: +``` + +### S3 Configuration File ```json { @@ -280,100 +524,128 @@ username and password. } ``` -### Data Directories +--- -#### Linux Directories +## 🌐 Remote Mounting -* `~/.local/repertory2/s3` -* `~/.local/repertory2/sia` - -#### Windows Directories - -* `%LOCALAPPDATA%\repertory2\s3` -* `%LOCALAPPDATA%\repertory2\sia` - * Examples: - * `C:\Users\Tom\AppData\Local\repertory2\s3` - * `C:\Users\Tom\AppData\Local\repertory2\sia` -* IMPORTANT: - * It is highly recommended to exclude this folder from any anti-virus/anti-malware applications as severe performance issues may arise. - * Excluding the mounted drive letter is also highly recommended. - -## Remote Mounting - -`repertory` allows local mounts to be shared with other computers on your network -or over the internet. This option is referred to as remote mounting. +`repertory` allows local mounts to be shared with other computers on your network or over the internet. This option is referred to as **remote mounting**. ### Server Setup -The following steps must be performed on the mount you wish to share with -other systems. Changes to configuration will not take affect while a mount is -active, so it is recommended to unmount beforehand. +The following steps must be performed on the mount you wish to share with other systems. Changes to configuration will not take effect while a mount is active, so it is recommended to unmount beforehand. -* Required steps: - * Enable remote mount: - * Sia - * `repertory -set RemoteMount.Enable true` - * `repertory --name '' -set RemoteMount.Enable true` - * S3: - * `repertory -s3 --name '' -set RemoteMount.Enable true` - * Set a secure encryption token: - * Sia: - * `repertory -set RemoteMount.EncryptionToken ''` - * `repertory --name '' -set RemoteMount.EncryptionToken ''` - * S3: - * `repertory -s3 --name '' -set RemoteMount.EncryptionToken ''` +**Required steps:** -* Optional steps: - * Change the port clients will use to connect to your mount: - * Sia: - * `repertory -set RemoteMount.ApiPort 20000` - * `repertory --name '' -set RemoteMount.ApiPort 20000` - * S3: - * `repertory -s3 --name '' -set RemoteMount.ApiPort 20000` +- Enable remote mount: -* IMPORTANT: - * Be sure to configure your firewall to allow incoming TCP connections on the port configured in `RemoteMount.ApiPort`. + - **Sia** + + ``` shell + repertory -set RemoteMount.Enable true + repertory --name '' -set RemoteMount.Enable true + ``` + + - **S3** + + ``` shell + repertory -set RemoteMount.Enable true + repertory -s3 --name '' -set RemoteMount.Enable true + ``` + +- Set a secure encryption token: + + - **Sia** + + ``` shell + repertory -set RemoteMount.EncryptionToken '' + repertory --name '' -set RemoteMount.EncryptionToken '' + ``` + + - **S3** + + ``` shell + repertory -s3 --name '' -set RemoteMount.EncryptionToken '' + ``` + +**Optional steps:** + +- Change the port clients will use to connect to your mount: + + - **Sia** + + ``` shell + repertory -set RemoteMount.ApiPort 20000 + repertory --name '' -set RemoteMount.ApiPort 20000 + ``` + + - **S3** + + ``` shell + repertory -s3 --name '' -set RemoteMount.ApiPort 20000 + ``` + +**IMPORTANT:** + +Be sure to configure your firewall to allow incoming TCP connections on the port configured in `RemoteMount.ApiPort`. #### Remote Mount Configuration File Section ```json { - ... "RemoteMount": { "ApiPort": 20000, "ClientPoolSize": 20, "Enable": true, "EncryptionToken": "" - }, - ... + } } ``` ### Client Setup -Client configuration is provider agnostic, so there's no need to specify `-s3` -for S3 providers. +Client configuration is provider agnostic, so there's no need to specify `-s3` for S3 providers. -* Required steps: - * Set the encryption token to the same value configured during server setup: - * `repertory -rm : -set RemoteConfig.EncryptionToken ''` - * Replace `` with the host name or IP of the server - * Replace `` with the value of `RemoteMount.ApiPort` used in the server configuration - * Example: - * `repertory -rm 192.168.1.10:20000 -set RemoteConfig.EncryptionToken ''` - * `repertory -rm my.host.com:20000 -set RemoteConfig.EncryptionToken ''` +**Required steps:** + +- Set the encryption token to the same value configured during server setup: + +``` shell +repertory -rm : -set RemoteConfig.EncryptionToken '' +# Replace with the host name or IP of the server +# Replace with the value of RemoteMount.ApiPort used in the server configuration +# Example: +repertory -rm 192.168.1.10:20000 -set RemoteConfig.EncryptionToken '' +repertory -rm my.host.com:20000 -set RemoteConfig.EncryptionToken '' +``` #### Client Remote Mounting -* Linux: - * `repertory -rm : /mnt/location` - * Example: - * `repertory -rm 192.168.1.10:20000 /mnt/location` + +##### Linux -* Windows: - * `repertory -rm : t:` - * Example: - * `repertory -rm 192.168.1.10:20000 t:` +``` shell +repertory -rm : /mnt/location +# Example: +repertory -rm 192.168.1.10:20000 /mnt/location +``` + + +##### macOS + +``` shell +repertory -rm : /Volumes/remotemount +# Example: +repertory -rm 192.168.1.10:20000 /Volumes/remotemount +``` + + +##### Windows + +``` shell +repertory -rm : t: +# Example: +repertory -rm 192.168.1.10:20000 t: +``` #### Remote Mount Configuration File @@ -397,67 +669,108 @@ for S3 providers. } ``` -## Compiling +--- -Successful compilation will result in all files required for execution to be placed -in the `dist/` directory +## 🧰 Compiling + +Successful compilation will place all required files for execution in the `dist/` directory. ### Linux Compilation -* Ensure `docker` is installed - * For x86_64: - * RelWithDebInfo: `scripts/make_unix.sh` - * Release: `scripts/make_unix.sh x86_64 Release` - * Debug: `scripts/make_unix.sh x86_64 Debug` +- Ensure `docker` is installed - * For aarch64: - * RelWithDebInfo: `scripts/make_unix.sh aarch64` - * Release: `scripts/make_unix.sh aarch64 Release` - * Debug: `scripts/make_unix.sh aarch64 Debug` +- For `x86_64`: + + ``` shell + scripts/make_unix.sh x86_64 + scripts/make_unix.sh x86_64 Release + scripts/make_unix.sh x86_64 Debug + ``` + +- For `aarch64`: + + ``` shell + scripts/make_unix.sh aarch64 + scripts/make_unix.sh aarch64 Release + scripts/make_unix.sh aarch64 Debug + ``` + +### macOS Compilation + +- Ensure `Xcode` and `CMake` are installed + +- For `x86_64`: + + ``` shell + scripts/make_unix.sh x86_64 + scripts/make_unix.sh x86_64 Release + scripts/make_unix.sh x86_64 Debug + ``` + +- For `aarch64`: + + ``` shell + scripts/make_unix.sh aarch64 + scripts/make_unix.sh aarch64 Release + scripts/make_unix.sh aarch64 Debug + ``` ### Windows Compilation -* OFFICIAL: Cross-compiling on Linux - * Ensure `docker` is installed - * RelWithDebInfo: `scripts/make_win32.sh` - * Release: `scripts/make_win32.sh x86_64 Release` - * Debug: `scripts/make_win32.sh x86_64 Debug` +- **OFFICIAL: Cross-compiling on Linux** -* UNOFFICIAL: Compiling on Windows - * Ensure latest [MSYS2](https://www.msys2.org/) is installed - * RelWithDebInfo: `scripts\make_win32.cmd` - * Release: `scripts\make_win32.cmd x86_64 Release` - * Debug: `scripts\make_win32.cmd x86_64 Debug` + - Ensure `docker` is installed -## Credits + ``` shell + scripts/make_win32.sh x86_64 + scripts/make_win32.sh x86_64 Release + scripts/make_win32.sh x86_64 Debug + ``` -* [binutils](https://www.gnu.org/software/binutils/) -* [boost c++ libraries](https://www.boost.org/) -* [cpp-httplib](https://github.com/yhirose/cpp-httplib) -* [curl](https://curl.haxx.se/) -* [docker](https://www.docker.com/) -* [Google Test](https://github.com/google/googletest) -* [ICU](https://icu.unicode.org/) -* [JSON for Modern C++](https://github.com/nlohmann/json) -* [libexpat](https://github.com/libexpat/libexpat) -* [libfuse](https://github.com/libfuse/libfuse) -* [libsodium](https://doc.libsodium.org/) -* [mingw-w64](https://www.mingw-w64.org/) -* [MSYS2](https://www.msys2.org) -* [OpenSSL](https://www.openssl.org/) -* [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) -* [pugixml](https://pugixml.org/) -* [RocksDB](https://rocksdb.org) -* [ScPrime](https://scpri.me/) -* [Sia Decentralized Cloud Storage](https://sia.tech/) -* [spdlog](https://github.com/gabime/spdlog) -* [SQLite](https://www.sqlite.org) -* [stduuid](https://github.com/mariusbancila/stduuid) -* [Storj](https://storj.io/) -* [WinFSP - FUSE for Windows](https://github.com/billziss-gh/winfsp) -* [zlib](https://zlib.net/) +- **UNOFFICIAL: Compiling on Windows** -## Developer Public Key + - Ensure latest [MSYS2](https://www.msys2.org/) is installed + + ``` shell + scripts\make_win32.cmd x86_64 + scripts\make_win32.cmd x86_64 Release + scripts\make_win32.cmd x86_64 Debug + ``` + +--- + +## 📜 Credits + +- [binutils](https://www.gnu.org/software/binutils/) +- [boost c++ libraries](https://www.boost.org/) +- [cpp-httplib](https://github.com/yhirose/cpp-httplib) +- [curl](https://curl.haxx.se/) +- [docker](https://www.docker.com/) +- [Google Test](https://github.com/google/googletest) +- [ICU](https://icu.unicode.org/) +- [JSON for Modern C++](https://github.com/nlohmann/json) +- [libexpat](https://github.com/libexpat/libexpat) +- [libfuse](https://github.com/libfuse/libfuse) +- [libsodium](https://doc.libsodium.org/) +- [macFUSE](https://macfuse.github.io/) +- [mingw-w64](https://www.mingw-w64.org/) +- [MSYS2](https://www.msys2.org) +- [OpenSSL](https://www.openssl.org/) +- [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) +- [pugixml](https://pugixml.org/) +- [RocksDB](https://rocksdb.org) +- [ScPrime](https://scpri.me/) +- [Sia Decentralized Cloud Storage](https://sia.tech/) +- [spdlog](https://github.com/gabime/spdlog) +- [SQLite](https://www.sqlite.org) +- [stduuid](https://github.com/mariusbancila/stduuid) +- [Storj](https://www.storj.io/) +- [WinFSP - FUSE for Windows](https://github.com/billziss-gh/winfsp) +- [zlib](https://zlib.net/) + +--- + +## 🔑 Developer Public Key ```text -----BEGIN PUBLIC KEY----- diff --git a/assets/blue/icon_24X24.png b/assets/blue/icon_24X24.png new file mode 100644 index 00000000..7f4dad4d Binary files /dev/null and b/assets/blue/icon_24X24.png differ diff --git a/assets/blue/icon_40x40.png b/assets/blue/icon_40x40.png new file mode 100644 index 00000000..9ac8d417 Binary files /dev/null and b/assets/blue/icon_40x40.png differ diff --git a/assets/blue/icon_48x48.png b/assets/blue/icon_48x48.png new file mode 100644 index 00000000..b2260374 Binary files /dev/null and b/assets/blue/icon_48x48.png differ diff --git a/assets/blue/logo.icns b/assets/blue/logo.icns new file mode 100644 index 00000000..5e1828b9 Binary files /dev/null and b/assets/blue/logo.icns differ diff --git a/assets/blue/logo.iconset/icon_128x128.png b/assets/blue/logo.iconset/icon_128x128.png new file mode 100644 index 00000000..7399beb3 Binary files /dev/null and b/assets/blue/logo.iconset/icon_128x128.png differ diff --git a/assets/blue/logo.iconset/icon_128x128@2x.png b/assets/blue/logo.iconset/icon_128x128@2x.png new file mode 100644 index 00000000..92a92dd0 Binary files /dev/null and b/assets/blue/logo.iconset/icon_128x128@2x.png differ diff --git a/assets/blue/logo.iconset/icon_16x16.png b/assets/blue/logo.iconset/icon_16x16.png new file mode 100644 index 00000000..7136174f Binary files /dev/null and b/assets/blue/logo.iconset/icon_16x16.png differ diff --git a/assets/blue/logo.iconset/icon_16x16@2x.png b/assets/blue/logo.iconset/icon_16x16@2x.png new file mode 100644 index 00000000..711f3395 Binary files /dev/null and b/assets/blue/logo.iconset/icon_16x16@2x.png differ diff --git a/assets/blue/logo.iconset/icon_256x256.png b/assets/blue/logo.iconset/icon_256x256.png new file mode 100644 index 00000000..92a92dd0 Binary files /dev/null and b/assets/blue/logo.iconset/icon_256x256.png differ diff --git a/assets/blue/logo.iconset/icon_256x256@2x.png b/assets/blue/logo.iconset/icon_256x256@2x.png new file mode 100644 index 00000000..f168b54e Binary files /dev/null and b/assets/blue/logo.iconset/icon_256x256@2x.png differ diff --git a/assets/blue/logo.iconset/icon_32x32.png b/assets/blue/logo.iconset/icon_32x32.png new file mode 100644 index 00000000..711f3395 Binary files /dev/null and b/assets/blue/logo.iconset/icon_32x32.png differ diff --git a/assets/blue/logo.iconset/icon_32x32@2x.png b/assets/blue/logo.iconset/icon_32x32@2x.png new file mode 100644 index 00000000..073d9490 Binary files /dev/null and b/assets/blue/logo.iconset/icon_32x32@2x.png differ diff --git a/assets/blue/logo.iconset/icon_512x512.png b/assets/blue/logo.iconset/icon_512x512.png new file mode 100644 index 00000000..f168b54e Binary files /dev/null and b/assets/blue/logo.iconset/icon_512x512.png differ diff --git a/assets/blue/logo.iconset/icon_512x512@2x.png b/assets/blue/logo.iconset/icon_512x512@2x.png new file mode 100644 index 00000000..fb28f9d6 Binary files /dev/null and b/assets/blue/logo.iconset/icon_512x512@2x.png differ diff --git a/assets/blue/logo.iconset/icon_64x64.png b/assets/blue/logo.iconset/icon_64x64.png new file mode 100644 index 00000000..073d9490 Binary files /dev/null and b/assets/blue/logo.iconset/icon_64x64.png differ diff --git a/assets/blue/logo.iconset/icon_64x64@2x.png b/assets/blue/logo.iconset/icon_64x64@2x.png new file mode 100644 index 00000000..7399beb3 Binary files /dev/null and b/assets/blue/logo.iconset/icon_64x64@2x.png differ diff --git a/assets/blue/logo.iconset/logo_1024x1024.png b/assets/blue/logo.iconset/logo_1024x1024.png new file mode 100644 index 00000000..fb28f9d6 Binary files /dev/null and b/assets/blue/logo.iconset/logo_1024x1024.png differ diff --git a/assets/green/icon_24X24.png b/assets/green/icon_24X24.png new file mode 100644 index 00000000..eda16c4d Binary files /dev/null and b/assets/green/icon_24X24.png differ diff --git a/assets/green/icon_40x40.png b/assets/green/icon_40x40.png new file mode 100644 index 00000000..09fee099 Binary files /dev/null and b/assets/green/icon_40x40.png differ diff --git a/assets/green/icon_48x48.png b/assets/green/icon_48x48.png new file mode 100644 index 00000000..a9901a54 Binary files /dev/null and b/assets/green/icon_48x48.png differ diff --git a/assets/green/logo.icns b/assets/green/logo.icns new file mode 100644 index 00000000..ca850466 Binary files /dev/null and b/assets/green/logo.icns differ diff --git a/assets/green/logo.iconset/icon_128x128.png b/assets/green/logo.iconset/icon_128x128.png new file mode 100644 index 00000000..563e25bf Binary files /dev/null and b/assets/green/logo.iconset/icon_128x128.png differ diff --git a/assets/green/logo.iconset/icon_128x128@2x.png b/assets/green/logo.iconset/icon_128x128@2x.png new file mode 100644 index 00000000..531a7466 Binary files /dev/null and b/assets/green/logo.iconset/icon_128x128@2x.png differ diff --git a/assets/green/logo.iconset/icon_16x16.png b/assets/green/logo.iconset/icon_16x16.png new file mode 100644 index 00000000..9232da4d Binary files /dev/null and b/assets/green/logo.iconset/icon_16x16.png differ diff --git a/assets/green/logo.iconset/icon_16x16@2x.png b/assets/green/logo.iconset/icon_16x16@2x.png new file mode 100644 index 00000000..ea39c611 Binary files /dev/null and b/assets/green/logo.iconset/icon_16x16@2x.png differ diff --git a/assets/green/logo.iconset/icon_256x256.png b/assets/green/logo.iconset/icon_256x256.png new file mode 100644 index 00000000..ea3dca02 Binary files /dev/null and b/assets/green/logo.iconset/icon_256x256.png differ diff --git a/assets/green/logo.iconset/icon_256x256@2x.png b/assets/green/logo.iconset/icon_256x256@2x.png new file mode 100644 index 00000000..af7cdbe7 Binary files /dev/null and b/assets/green/logo.iconset/icon_256x256@2x.png differ diff --git a/assets/green/logo.iconset/icon_32x32.png b/assets/green/logo.iconset/icon_32x32.png new file mode 100644 index 00000000..408cf816 Binary files /dev/null and b/assets/green/logo.iconset/icon_32x32.png differ diff --git a/assets/green/logo.iconset/icon_32x32@2x.png b/assets/green/logo.iconset/icon_32x32@2x.png new file mode 100644 index 00000000..f01cbd34 Binary files /dev/null and b/assets/green/logo.iconset/icon_32x32@2x.png differ diff --git a/assets/green/logo.iconset/icon_512x512.png b/assets/green/logo.iconset/icon_512x512.png new file mode 100644 index 00000000..7b439932 Binary files /dev/null and b/assets/green/logo.iconset/icon_512x512.png differ diff --git a/assets/green/logo.iconset/icon_512x512@2x.png b/assets/green/logo.iconset/icon_512x512@2x.png new file mode 100644 index 00000000..e7125796 Binary files /dev/null and b/assets/green/logo.iconset/icon_512x512@2x.png differ diff --git a/assets/green/logo.iconset/icon_64x64.png b/assets/green/logo.iconset/icon_64x64.png new file mode 100644 index 00000000..0a97ba74 Binary files /dev/null and b/assets/green/logo.iconset/icon_64x64.png differ diff --git a/assets/green/logo.iconset/icon_64x64@2x.png b/assets/green/logo.iconset/icon_64x64@2x.png new file mode 100644 index 00000000..fb194469 Binary files /dev/null and b/assets/green/logo.iconset/icon_64x64@2x.png differ diff --git a/assets/green/logo.iconset/logo_1024x1024.png b/assets/green/logo.iconset/logo_1024x1024.png new file mode 100644 index 00000000..af98d2b7 Binary files /dev/null and b/assets/green/logo.iconset/logo_1024x1024.png differ diff --git a/assets/home.png b/assets/home.png new file mode 100644 index 00000000..751352ea Binary files /dev/null and b/assets/home.png differ diff --git a/assets/icon.icns b/assets/icon.icns new file mode 100644 index 00000000..5e1828b9 Binary files /dev/null and b/assets/icon.icns differ diff --git a/assets/icon.ico b/assets/icon.ico new file mode 100644 index 00000000..ca63e588 Binary files /dev/null and b/assets/icon.ico differ diff --git a/assets/login.png b/assets/login.png new file mode 100644 index 00000000..ec1ecbb2 Binary files /dev/null and b/assets/login.png differ diff --git a/assets/logo_blue.xcf b/assets/logo_blue.xcf new file mode 100644 index 00000000..2fc3c12e Binary files /dev/null and b/assets/logo_blue.xcf differ diff --git a/assets/logo_green.xcf b/assets/logo_green.xcf new file mode 100644 index 00000000..e7fd31bd Binary files /dev/null and b/assets/logo_green.xcf differ diff --git a/cmake/flags.cmake b/cmake/flags.cmake index b6691f55..78b1e7ef 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -35,13 +35,9 @@ list(APPEND PROJECT_CXXFLAGS_LIST -Wcast-align -Wconversion -Wdouble-promotion - -Wduplicated-branches - -Wduplicated-cond -Wextra -Wformat=2 - -Wlogical-op -Wmisleading-indentation - -Wno-useless-cast -Wnon-virtual-dtor -Wnull-dereference -Wold-style-cast @@ -52,6 +48,15 @@ list(APPEND PROJECT_CXXFLAGS_LIST -Wunused ) +if (NOT PROJECT_IS_DARWIN) + list(APPEND PROJECT_CXXFLAGS_LIST + -Wduplicated-branches + -Wduplicated-cond + -Wlogical-op + -Wno-useless-cast + ) +endif() + list(APPEND PROJECT_CFLAGS_LIST ${PROJECT_COMMON_FLAG_LIST} -std=c${CMAKE_C_STANDARD} @@ -62,7 +67,7 @@ list(APPEND PROJECT_CXXFLAGS_LIST -std=gnu++${CMAKE_CXX_STANDARD} ) -if(PROJECT_STATIC_LINK) +if(NOT PROJECT_IS_DARWIN AND PROJECT_STATIC_LINK) list(APPEND PROJECT_CMAKE_EXE_LINKER_FLAGS -static-libgcc -static-libstdc++ @@ -89,7 +94,11 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${PROJECT_RELEASE_FLAG_L set(CMAKE_EXE_LINKER_FLAGS "${PROJECT_CMAKE_EXE_LINKER_FLAGS}") -set(EXTERNAL_CMAKE_CXX_FLAGS "-include cstdint -include utility -fext-numeric-literals ${PROJECT_COMMON_FLAG_LIST}") +set(EXTERNAL_CMAKE_CXX_FLAGS "-include cstdint -include utility ${PROJECT_COMMON_FLAG_LIST}") +if (NOT PROJECT_IS_DARWIN) + set(EXTERNAL_CMAKE_CXX_FLAGS "-fext-numeric-literals ${EXTERNAL_CMAKE_CXX_FLAGS}") +endif() + list(APPEND PROJECT_EXTERNAL_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=${PROJECT_CMAKE_BUILD_TYPE} -DCMAKE_COLOR_MAKEFILE=${CMAKE_COLOR_MAKEFILE} diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 2bcedf85..fd1d2ece 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -1,3 +1,7 @@ +if (PROJECT_MACOS_ICNS_NAME) + set(PROJECT_MACOS_ICNS_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/assets/${PROJECT_MACOS_ICNS_NAME}") +endif() + function(set_common_target_options name) target_compile_definitions(${name} PUBLIC ${PROJECT_DEFINITIONS} @@ -12,6 +16,17 @@ function(set_common_target_options name) ${PROJECT_EXTERNAL_BUILD_ROOT}/lib ) + if (PROJECT_STATIC_LINK) + target_compile_definitions(${name} PRIVATE U_STATIC_IMPLEMENTATION) + endif() + + target_link_libraries(${name} PRIVATE + ICU::io + ICU::i18n + ICU::uc + ICU::data + ) + target_include_directories(${name} AFTER PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include ${name}_INCLUDES @@ -31,11 +46,31 @@ function(add_project_executable2 name dependencies libraries headers sources is_ list(APPEND sources ${PROJECT_WINDOWS_VERSION_RC}) endif() - add_executable(${name} - ${headers} - ${sources} - ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/main.cpp - ) + if (PROJECT_IS_DARWIN AND PROJECT_MACOS_ICNS_SOURCE AND "${name}" STREQUAL "${PROJECT_NAME}") + set_source_files_properties(${PROJECT_MACOS_ICNS_SOURCE} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources" + ) + + add_executable(${name} + MACOSX_BUNDLE + ${headers} + ${sources} + ${PROJECT_MACOS_ICNS_SOURCE} + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/main.cpp + ) + + set_target_properties(${name} PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_ICON_FILE "${PROJECT_MACOS_ICNS_NAME}" + RESOURCE "${PROJECT_MACOS_ICNS_SOURCE}" + ) + else() + add_executable(${name} + ${headers} + ${sources} + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/main.cpp + ) + endif() foreach(dependency ${dependencies}) set_common_target_options(${dependency}) diff --git a/cmake/hashes.cmake b/cmake/hashes.cmake index 1941d048..e2c3dac9 100644 --- a/cmake/hashes.cmake +++ b/cmake/hashes.cmake @@ -1,20 +1,22 @@ set(BINUTILS_HASH ce2017e059d63e67ddb9240e9d4ec49c2893605035cd60e92ad53177f4377237) set(BOOST2_HASH 7bd7ddceec1a1dfdcbdb3e609b60d01739c38390a5f956385a12f3122049f0ca) -set(BOOST_HASH 3621533e820dcab1e8012afd583c0c73cf0f77694952b81352bf38c1488f9cb4) -set(CPP_HTTPLIB_HASH 410a1347ed6bcbcc4a19af8ed8ad3873fe9fa97731d52db845c4c78f3f9c31e6) -set(CURL_HASH 2937cadde007aa3a52a17c21ac9153ea054700f37926d1d96602bf07e888c847) +set(BOOST_HASH 9de758db755e8330a01d995b0a24d09798048400ac25c03fc5ea9be364b13c93) +set(CPP_HTTPLIB_HASH a66f908f50ccb119769adce44fe1eac75f81b6ffab7c4ac0211bb663ffeb2688) +set(CURL_HASH d4d9a5001b491f5726efe9b50bc4aad03029506e73c9261272e809c64b05e814) set(EXPAT_HASH 85372797ff0673a8fc4a6be16466bb5a0ca28c0dcf3c6f7ac1686b4a3ba2aabb) -set(GCC_HASH 51b9919ea69c980d7a381db95d4be27edf73b21254eb13d752a08003b4d013b1) +set(GCC_HASH 7294d65cc1a0558cb815af0ca8c7763d86f7a31199794ede3f630c0d1b0a5723) set(GTEST_HASH 65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c) set(ICU_HASH a2c443404f00098e9e90acf29dc318e049d2dc78d9ae5f46efb261934a730ce2) +set(INNOSETUP_HASH fa73bf47a4da250d185d07561c2bfda387e5e20db77e4570004cf6a133cc10b1) set(JSON_HASH 4b92eb0c06d10683f7447ce9406cb97cd4b453be18d7279320f7b2f025c10187) set(LIBSODIUM_HASH 8e5aeca07a723a27bbecc3beef14b0068d37e7fc0e97f51b3f1c82d2a58005c1) set(MINGW_HASH 5afe822af5c4edbf67daaf45eec61d538f49eef6b19524de64897c6b95828caf) -set(OPENSSL_HASH 529043b15cffa5f36077a4d0af83f3de399807181d607441d734196d889b641f) +set(OPENSSL_HASH b6a5f44b7eb69e3fa35dbf15524405b44837a481d43d81daddde3ff21fcbb8e9) set(PKG_CONFIG_HASH 6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591) set(PUGIXML_HASH 655ade57fa703fb421c2eb9a0113b5064bddb145d415dd1f88c79353d90d511a) -set(ROCKSDB_HASH afccfab496556904900afacf7d99887f1d50cb893e5d2288bd502db233adacac) +set(ROCKSDB_HASH 7ec942baab802b2845188d02bc5d4e42c29236e61bcbc08f5b3a6bdd92290c22) set(SPDLOG_HASH 15a04e69c222eb6c01094b5c7ff8a249b36bb22788d72519646fb85feb267e67) -set(SQLITE_HASH 9ad6d16cbc1df7cd55c8b55127c82a9bca5e9f287818de6dc87e04e73599d754) +set(SQLITE_HASH 1d3049dd0f830a025a53105fc79fd2ab9431aea99e137809d064d8ee8356b032) set(STDUUID_HASH b1176597e789531c38481acbbed2a6894ad419aab0979c10410d59eb0ebf40d3) +set(WINFSP_HASH 073a70e00f77423e34bed98b86e600def93393ba5822204fac57a29324db9f7a) set(ZLIB_HASH 17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c) diff --git a/cmake/libraries.cmake b/cmake/libraries.cmake index 5f955464..cb820b7d 100644 --- a/cmake/libraries.cmake +++ b/cmake/libraries.cmake @@ -4,13 +4,17 @@ set(Boost_USE_STATIC_LIBS ${PROJECT_STATIC_LINK}) set(CURL_USE_STATIC_LIBS ${PROJECT_STATIC_LINK}) set(OPENSSL_USE_STATIC_LIBS ${PROJECT_STATIC_LINK}) set(SFML_STATIC_LIBRARIES ${PROJECT_STATIC_LINK}) -set(ZLIB_USE_STATIC_LIBS ${PROJECT_STATIC_LINK}) +if (PROJECT_IS_DARWIN) + set(ZLIB_USE_STATIC_LIBS OFF) +else() + set(ZLIB_USE_STATIC_LIBS ${PROJECT_STATIC_LINK}) +endif() set(wxWidgets_USE_STATIC ${PROJECT_STATIC_LINK}) +set(ICU_USE_STATIC_LIBS ${PROJECT_STATIC_LINK}) +include(cmake/libraries/icu.cmake) include(cmake/libraries/openssl.cmake) - include(cmake/libraries/boost.cmake) - include(cmake/libraries/cpp_httplib.cmake) include(cmake/libraries/curl.cmake) include(cmake/libraries/fuse.cmake) @@ -59,7 +63,7 @@ if(PROJECT_BUILD) winspool ws2_32 ) - else() + elseif(NOT PROJECT_IS_DARWIN) link_libraries( uring ) diff --git a/cmake/libraries/boost.cmake b/cmake/libraries/boost.cmake index 99825e4b..f3609603 100644 --- a/cmake/libraries/boost.cmake +++ b/cmake/libraries/boost.cmake @@ -39,6 +39,14 @@ if(PROJECT_ENABLE_BOOST) wserialization ) else() + if(PROJECT_IS_DARWIN) + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(CMAKE_THREAD_LIBS_INIT "-lpthread") + set(CMAKE_USE_PTHREADS_INIT 1) + set(CMAKE_USE_WIN32_THREADS_INIT 0) + set(THREADS_PREFER_PTHREAD_FLAG ON) + endif() + find_package(Boost ${BOOST_MAJOR_VERSION}.${BOOST_MINOR_VERSION}.${BOOST_PATCH_VERSION} REQUIRED COMPONENTS @@ -54,7 +62,6 @@ if(PROJECT_ENABLE_BOOST) random regex serialization - system thread wserialization ) @@ -120,10 +127,12 @@ if(PROJECT_ENABLE_BOOST) --with-libraries=atomic,chrono,date_time,filesystem,iostreams,locale,log,program_options,random,regex,serialization,system,test,thread BUILD_COMMAND ./b2 + -sNO_BZIP2=1 -j$ENV{CMAKE_BUILD_PARALLEL_LEVEL} ${BOOST_BUILD_ARGS} INSTALL_COMMAND ./b2 + -sNO_BZIP2=1 -j$ENV{CMAKE_BUILD_PARALLEL_LEVEL} ${BOOST_BUILD_ARGS} install @@ -131,6 +140,10 @@ if(PROJECT_ENABLE_BOOST) list(APPEND PROJECT_DEPENDENCIES boost_project) + if(PROJECT_IS_DARWIN OR PROJECT_REQUIRE_ALPINE) + add_dependencies(boost_project icu_project) + endif() + if (NOT CMAKE_HOST_WIN32) add_dependencies(boost_project openssl_project) endif() diff --git a/cmake/libraries/cpp_httplib.cmake b/cmake/libraries/cpp_httplib.cmake index 019075b1..57c0ece4 100644 --- a/cmake/libraries/cpp_httplib.cmake +++ b/cmake/libraries/cpp_httplib.cmake @@ -15,6 +15,7 @@ if(PROJECT_ENABLE_CPP_HTTPLIB) CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} -DBUILD_STATIC_LIBS=ON + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DHTTPLIB_REQUIRE_BROTLI=OFF -DHTTPLIB_REQUIRE_OPENSSL=ON -DHTTPLIB_REQUIRE_ZLIB=ON diff --git a/cmake/libraries/curl.cmake b/cmake/libraries/curl.cmake index ae0cee71..133f17ac 100644 --- a/cmake/libraries/curl.cmake +++ b/cmake/libraries/curl.cmake @@ -27,8 +27,8 @@ if(PROJECT_ENABLE_CURL) -DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} -DBUILD_STATIC_CURL=ON -DBUILD_STATIC_LIBS=ON - -DBUILD_STATIC_LIBS=ON -DBUILD_TESTING=OFF + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DCURL_BROTLI=OFF -DCURL_CA_BUNDLE=./cacert.pem -DCURL_CA_FALLBACK=ON @@ -37,11 +37,13 @@ if(PROJECT_ENABLE_CURL) -DCURL_USE_LIBSSH2=OFF -DCURL_USE_OPENSSL=${PROJECT_ENABLE_OPENSSL} -DCURL_ZLIB=ON + -DCURL_ZSTD=OFF -DENABLE_CURL_MANUAL=OFF -DENABLE_THREADED_RESOLVER=ON -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS} -DUSE_LIBIDN2=OFF + -DUSE_NGHTTP2=OFF -DZLIB_USE_STATIC_LIBS=${ZLIB_USE_STATIC_LIBS} ) diff --git a/cmake/libraries/fuse.cmake b/cmake/libraries/fuse.cmake index bb9883fe..6e45d35e 100644 --- a/cmake/libraries/fuse.cmake +++ b/cmake/libraries/fuse.cmake @@ -20,17 +20,25 @@ if(PROJECT_ENABLE_FUSE AND NOT PROJECT_IS_MINGW) endif() endif() else() - pkg_check_modules(LIBFUSE3 fuse3>=3.0.0) - if(LIBFUSE3_FOUND) - set(PROJECT_FUSE fuse3) - set(PROJECT_FUSE_INCLUDE_DIRS ${LIBFUSE3_INCLUDE_DIRS}) + if (PROJECT_IS_DARWIN) + find_library(OSXFUSE NO_CACHE NAMES OSXFUSE) + if (NOT OSXFUSE) + message(FATAL_ERROR "FUSE for macOS not found (https://macfuse.github.io)") + endif () + set(PROJECT_FUSE fuse2) else() - pkg_check_modules(LIBFUSE2 fuse>=2.9.0) - if(LIBFUSE2_FOUND) - set(PROJECT_FUSE fuse2) - set(PROJECT_FUSE_INCLUDE_DIRS ${LIBFUSE2_INCLUDE_DIRS}) + pkg_check_modules(LIBFUSE3 fuse3>=3.0.0) + if(LIBFUSE3_FOUND) + set(PROJECT_FUSE fuse3) + set(PROJECT_FUSE_INCLUDE_DIRS ${LIBFUSE3_INCLUDE_DIRS}) else() - message(FATAL_ERROR "fuse library not found") + pkg_check_modules(LIBFUSE2 fuse>=2.9.0) + if(LIBFUSE2_FOUND) + set(PROJECT_FUSE fuse2) + set(PROJECT_FUSE_INCLUDE_DIRS ${LIBFUSE2_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "fuse library not found") + endif() endif() endif() endif() diff --git a/cmake/libraries/icu.cmake b/cmake/libraries/icu.cmake new file mode 100644 index 00000000..db8a2ddf --- /dev/null +++ b/cmake/libraries/icu.cmake @@ -0,0 +1,24 @@ +if((PROJECT_IS_DARWIN OR PROJECT_REQUIRE_ALPINE) AND NOT PROJECT_IS_MINGW AND NOT PROJECT_BUILD) + if(PROJECT_BUILD_SHARED_LIBS) + set(ICU_ENABLE_SHARED yes) + else() + set(ICU_ENABLE_SHARED no) + endif() + + ExternalProject_Add(icu_project + PREFIX external + URL ${PROJECT_3RD_PARTY_DIR}/mingw64/icu-release-${ICU_VERSION}.tar.gz + URL_HASH SHA256=${ICU_HASH} + BUILD_IN_SOURCE 1 + LIST_SEPARATOR | + PATCH_COMMAND chmod +x ${PROJECT_3RD_PARTY_DIR}/icu_configure.sh + CONFIGURE_COMMAND cd icu4c/source && ${PROJECT_3RD_PARTY_DIR}/icu_configure.sh + ${PROJECT_MARCH} + ${PROJECT_EXTERNAL_BUILD_ROOT} + ${ICU_ENABLE_SHARED} + BUILD_COMMAND cd icu4c/source && make -j$ENV{CMAKE_BUILD_PARALLEL_LEVEL} + INSTALL_COMMAND cd icu4c/source && make install + ) + + list(APPEND PROJECT_DEPENDENCIES icu_project) +endif() diff --git a/cmake/libraries/json.cmake b/cmake/libraries/json.cmake index 632e6ba6..1a08005c 100644 --- a/cmake/libraries/json.cmake +++ b/cmake/libraries/json.cmake @@ -18,6 +18,7 @@ if(PROJECT_ENABLE_JSON) CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} -DBUILD_STATIC_LIBS=ON + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DJSON_BuildTests=OFF -DJSON_Install=ON -DJSON_MultipleHeaders=OFF diff --git a/cmake/libraries/openssl.cmake b/cmake/libraries/openssl.cmake index 942aa069..e90d50ef 100644 --- a/cmake/libraries/openssl.cmake +++ b/cmake/libraries/openssl.cmake @@ -15,6 +15,12 @@ if(PROJECT_ENABLE_OPENSSL) elseif(NOT PROJECT_IS_MINGW) if(PROJECT_IS_MINGW) set(OPENSSL_COMPILE_TYPE mingw64) + elseif(PROJECT_IS_DARWIN) + if(PROJECT_IS_ARM64) + set(OPENSSL_COMPILE_TYPE darwin64-arm64) + else() + set(OPENSSL_COMPILE_TYPE darwin64-x86_64) + endif() elseif(PROJECT_IS_ARM64) set(OPENSSL_COMPILE_TYPE linux-aarch64) else() diff --git a/cmake/libraries/pugixml.cmake b/cmake/libraries/pugixml.cmake index 6427f11a..9f3ebf75 100644 --- a/cmake/libraries/pugixml.cmake +++ b/cmake/libraries/pugixml.cmake @@ -20,6 +20,7 @@ if(PROJECT_ENABLE_PUGIXML) CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} -DBUILD_STATIC_LIBS=ON + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} ) list(APPEND PROJECT_DEPENDENCIES pugixml_project) diff --git a/cmake/libraries/rocksdb.cmake b/cmake/libraries/rocksdb.cmake index 123748af..acf9d426 100644 --- a/cmake/libraries/rocksdb.cmake +++ b/cmake/libraries/rocksdb.cmake @@ -14,12 +14,14 @@ if(PROJECT_ENABLE_ROCKSDB) CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DFAIL_ON_WARNINGS=OFF -DPORTABLE=1 -DROCKSDB_BUILD_SHARED=OFF -DROCKSDB_INSTALL_ON_WINDOWS=ON -DWITH_BENCHMARK=OFF -DWITH_BENCHMARK_TOOLS=OFF + -DWITH_BZ2=OFF -DWITH_CORE_TOOLS=OFF -DWITH_EXAMPLES=OFF -DWITH_GFLAGS=OFF diff --git a/cmake/libraries/spdlog.cmake b/cmake/libraries/spdlog.cmake index 21972d54..f5dd23a3 100644 --- a/cmake/libraries/spdlog.cmake +++ b/cmake/libraries/spdlog.cmake @@ -15,6 +15,7 @@ if(PROJECT_ENABLE_SPDLOG) LIST_SEPARATOR | CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DSPDLOG_BUILD_EXAMPLE=OFF -DSPDLOG_FMT_EXTERNAL=OFF -DSPDLOG_FMT_EXTERNAL_HO=OFF diff --git a/cmake/libraries/stduuid.cmake b/cmake/libraries/stduuid.cmake index 87ffc05a..74b0db42 100644 --- a/cmake/libraries/stduuid.cmake +++ b/cmake/libraries/stduuid.cmake @@ -16,6 +16,7 @@ if(PROJECT_ENABLE_STDUUID) CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} -DBUILD_STATIC_LIBS=ON + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DUUID_BUILD_TESTS=OFF -DUUID_ENABLE_INSTALL=ON -DUUID_USING_CXX20_SPAN=ON diff --git a/cmake/libraries/testing.cmake b/cmake/libraries/testing.cmake index 5161d42e..a0012c67 100644 --- a/cmake/libraries/testing.cmake +++ b/cmake/libraries/testing.cmake @@ -10,6 +10,7 @@ if (PROJECT_ENABLE_TESTING) CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} -DBUILD_STATIC_LIBS=ON + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} ) list(APPEND PROJECT_DEPENDENCIES gtest_project) diff --git a/cmake/os.cmake b/cmake/os.cmake index 9604d745..b8f2a107 100644 --- a/cmake/os.cmake +++ b/cmake/os.cmake @@ -2,10 +2,6 @@ if(MSVC) message(FATAL_ERROR "MSVC will not be supported") endif() -if(UNIX AND APPLE) - message(FATAL_ERROR "Apple is not currently supported") -endif() - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") message(FATAL_ERROR "FreeBSD is not currently supported") endif() @@ -13,3 +9,15 @@ endif() if(PROJECT_REQUIRE_ALPINE AND NOT PROJECT_IS_ALPINE AND PROJECT_IS_MINGW AND PROJECT_IS_MINGW_UNIX) message(FATAL_ERROR "Project requires Alpine Linux to build") endif() + +if (PROJECT_IS_DARWIN) + if (PROJECT_IS_ARM64) + set(CMAKE_OSX_ARCHITECTURES "arm64") + else() + set(CMAKE_OSX_ARCHITECTURES "x86_64") + endif() +endif() + +if (PROJECT_IS_DARWIN AND NOT PROJECT_MACOS_BUNDLE_ID) + message(FATAL_ERROR "'PROJECT_MACOS_BUNDLE_ID' is not set in 'config.sh'") +endif() diff --git a/cmake/versions.cmake b/cmake/versions.cmake index 0bd00b33..0b3de7e4 100644 --- a/cmake/versions.cmake +++ b/cmake/versions.cmake @@ -3,25 +3,28 @@ 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_MINOR_VERSION 89) set(BOOST_PATCH_VERSION 0) -set(CPP_HTTPLIB_VERSION 0.23.1) -set(CURL2_VERSION 8_15_0) -set(CURL_VERSION 8.15.0) +set(CPP_HTTPLIB_VERSION 0.26.0) +set(CURL2_VERSION 8_16_0) +set(CURL_VERSION 8.16.0) set(EXPAT2_VERSION 2_7_1) set(EXPAT_VERSION 2.7.1) -set(GCC_VERSION 15.1.0) +set(GCC_VERSION 15.2.0) set(GTEST_VERSION 1.17.0) set(ICU_VERSION 76-1) +set(INNOSETUP_VERSION 6.5.4) set(JSON_VERSION 3.12.0) set(LIBSODIUM_VERSION 1.0.20) set(MINGW_VERSION 13.0.0) -set(OPENSSL_VERSION 3.5.1) +set(OPENSSL_VERSION 3.6.0) set(PKG_CONFIG_VERSION 0.29.2) set(PUGIXML_VERSION 1.15) -set(ROCKSDB_VERSION 10.4.2) +set(ROCKSDB_VERSION 10.5.1) set(SPDLOG_VERSION 1.15.3) -set(SQLITE2_VERSION 3.50.3) -set(SQLITE_VERSION 3500300) +set(SQLITE2_VERSION 3.50.4) +set(SQLITE_VERSION 3500400) set(STDUUID_VERSION 1.2.3) +set(WINFSP2_VERSION 2.1) +set(WINFSP_VERSION 2.1.25156) set(ZLIB_VERSION 1.3.1) diff --git a/config.sh b/config.sh index 5fe91976..b20a3bba 100755 --- a/config.sh +++ b/config.sh @@ -8,11 +8,14 @@ PROJECT_URL="${PROJECT_COMPANY_NAME}/repertory" PROJECT_COPYRIGHT="Copyright <2018-2025> <${PROJECT_URL}>" PROJECT_DESC="Mount utility for Sia and S3" +PROJECT_MACOS_BUNDLE_ID="com.fifthgrid.blockstorage.repertory" +PROJECT_MACOS_ICNS_NAME="icon.icns" + PROJECT_MAJOR_VERSION=2 -PROJECT_MINOR_VERSION=0 -PROJECT_REVISION_VERSION=7 +PROJECT_MINOR_VERSION=1 +PROJECT_REVISION_VERSION=0 PROJECT_RELEASE_NUM=1 -PROJECT_RELEASE_ITER=release +PROJECT_RELEASE_ITER=rc PROJECT_APP_LIST=(${PROJECT_NAME}) diff --git a/docker/aarch64/alpine b/docker/aarch64/alpine index dfac5959..192e70b4 100644 --- a/docker/aarch64/alpine +++ b/docker/aarch64/alpine @@ -1,5 +1,5 @@ #comment -FROM arm64v8/alpine:3.21.4 +FROM arm64v8/alpine:3.22.2 MAINTAINER Scott E. Graves CMD bash @@ -32,9 +32,6 @@ RUN apk add \ gflags-dev \ git \ git-lfs \ - icu-dev \ - icu-libs \ - icu-static \ libogg-dev \ libogg-static \ libtool \ diff --git a/docker/x86_64/alpine b/docker/x86_64/alpine index 2d7026cb..8974cfcf 100644 --- a/docker/x86_64/alpine +++ b/docker/x86_64/alpine @@ -1,5 +1,5 @@ #comment -FROM alpine:3.21.4 +FROM alpine:3.22.2 MAINTAINER Scott E. Graves CMD bash @@ -32,9 +32,6 @@ RUN apk add \ gflags-dev \ git \ git-lfs \ - icu-dev \ - icu-libs \ - icu-static \ libogg-dev \ libogg-static \ libtool \ diff --git a/docker/x86_64/flutter b/docker/x86_64/flutter index 20e14228..e086270b 100644 --- a/docker/x86_64/flutter +++ b/docker/x86_64/flutter @@ -11,7 +11,6 @@ RUN apt-get install -y \ gdb \ git \ lib32stdc++6 \ - libgconf-2-4 \ libglu1-mesa \ libstdc++6 \ python3 \ diff --git a/docker/x86_64/mingw64 b/docker/x86_64/mingw64 index bf93e5ca..e3cb821d 100644 --- a/docker/x86_64/mingw64 +++ b/docker/x86_64/mingw64 @@ -1,5 +1,5 @@ #comment -FROM alpine:3.21.4 +FROM alpine:3.22.2 RUN apk update RUN apk upgrade @@ -12,6 +12,7 @@ RUN apk add \ bzip2 \ clang17-extra-tools \ cmake \ + curl \ file \ flex \ g++ \ @@ -43,6 +44,7 @@ RUN apk add \ ruby \ texinfo \ unzip \ + xvfb \ wget \ wine \ xz \ @@ -102,6 +104,39 @@ RUN echo -e \ "system = 'windows'\n"\ > ${MY_TOOLCHAIN_FILE_MESON} +RUN mkdir -p /opt/bin;echo -e \ + "#!/bin/sh\n"\ + "COUNT=0\n"\ + "echo \"Start waiting on \$@\"\n"\ + "while pgrep \"\$@\" > /dev/null; do \n"\ + " echo \"waiting ...\"\n"\ + " sleep 1;\n"\ + " COUNT=\$((COUNT+1))\n"\ + " if [ \$COUNT -eq 60 ]; then\n"\ + " exit 3;\n"\ + " fi\n"\ + "done\n"\ + "echo \"\$@ completed\"\n"\ + > /opt/bin/waitonprocess && \ + chmod +x /opt/bin/waitonprocess && \ + cat /opt/bin/waitonprocess + +RUN echo -e \ + "#!/bin/sh\n"\ + "Xvfb \$DISPLAY &\n"\ + "tokill=\$!\n"\ + "wine wineboot --init\n"\ + "waitonprocess wineserver\n"\ + "\"\$@\"\n"\ + "retval=\$?\n"\ + "kill -15 \$tokill\n"\ + "wine wineboot --shutdown\n"\ + "return \$retval\n"\ + > /opt/bin/wine-x11-run && \ + chmod +x /opt/bin/wine-x11-run && \ + cat /opt/bin/wine-x11-run + +ENV PATH="/opt/bin:${PATH}" SHELL [ "/bin/bash", "-c" ] RUN mkdir -p \ @@ -711,6 +746,7 @@ RUN if [ -f "/3rd_party/cpp-httplib-${MY_CPP_HTTPLIB_VERSION}.tar.gz" ]; then \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_STANDARD=${MY_CXX_STANDARD} \ -DCMAKE_INSTALL_PREFIX=${MY_MINGW_DIR} \ + -DCMAKE_SYSTEM_VERSION="10.0.0" \ -DCMAKE_TOOLCHAIN_FILE=${MY_TOOLCHAIN_FILE_CMAKE} \ -DHTTPLIB_REQUIRE_BROTLI=OFF \ -DHTTPLIB_REQUIRE_OPENSSL=ON \ @@ -799,6 +835,7 @@ RUN if [ -f "/3rd_party/libevent-${MY_LIBEVENT_VERSION}-stable.tar.gz" ]; then \ && cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_STANDARD=${MY_CXX_STANDARD} \ + -DCMAKE_C_FLAGS="-include winsock2.h -include ws2tcpip.h -include iphlpapi.h" \ -DCMAKE_INSTALL_PREFIX=${MY_MINGW_DIR} \ -DCMAKE_TOOLCHAIN_FILE=${MY_TOOLCHAIN_FILE_CMAKE} \ -DEVENT__DISABLE_OPENSSL=ON \ @@ -888,6 +925,7 @@ RUN if [ -f "/3rd_party/rocksdb-${MY_ROCKSDB_VERSION}.tar.gz" ]; then \ -DROCKSDB_INSTALL_ON_WINDOWS=ON \ -DWITH_BENCHMARK=OFF \ -DWITH_BENCHMARK_TOOLS=OFF \ + -DWITH_BZ2=OFF \ -DWITH_CORE_TOOLS=OFF \ -DWITH_EXAMPLES=OFF \ -DWITH_GFLAGS=OFF \ @@ -1119,6 +1157,33 @@ RUN if [ -f "/3rd_party/libdsm-${MY_LIBDSM_VERSION}.tar.gz" ]; then \ && rm -r libdsm-${MY_LIBDSM_VERSION} \ ; fi -RUN (mv ${MY_MINGW_DIR}/lib/*.dll ${MY_MINGW_DIR}/bin || echo "no dll's found") \ +ENV DISPLAY=:90 +ENV WINEDEBUG=-all,err+all + +ARG INNOSETUP_VERSION +ENV MY_INNOSETUP_VERSION=${INNOSETUP_VERSION} +RUN rm -rf /root/.wine; \ + wine64 reg add 'HKEY_CURRENT_USER\Software\Wine' /v ShowDotFiles /d Y \ + && while [ ! -f /root/.wine/user.reg ]; do sleep 1; done; \ + wine-x11-run wine64 /3rd_party/mingw64/innosetup-${MY_INNOSETUP_VERSION}.exe /SP- /VERYSILENT /ALLUSERS /SUPPRESSMSGBOXES /DOWNLOADISCRYPT=1 + +ARG UID=1000 +ARG GID=1000 +ARG USERNAME=myuser + +RUN delgroup scanner || echo "no scanner group found" + +RUN addgroup -g $GID $USERNAME && \ + adduser -D -u $UID -G $USERNAME -h /home/$USERNAME $USERNAME + +RUN rsync -av --progress /root/.wine/ /home/$USERNAME/.wine/ && \ + chown -R $UID:$GID -R /home/$USERNAME/.wine/ + +RUN (cp ${MY_MINGW_DIR}/lib/*.dll ${MY_MINGW_DIR}/bin || echo "no dll's found") \ && chmod 0777 -R ${MY_MINGW_DIR} \ - && rm -rf /3rd_party + && rm -rf /3rd_party \ + && rm -rf /root/.wine + +USER $USERNAME +WORKDIR /home/$USERNAME + diff --git a/post_build.sh b/post_build.sh index 4f5435c6..f9b107dd 100755 --- a/post_build.sh +++ b/post_build.sh @@ -8,3 +8,7 @@ rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_in rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_input/ \ ${PROJECT_DIST_DIR}/test_input/ + +rsync -av --progress ${CURRENT_DIR}/assets/icon.ico ${PROJECT_DIST_DIR}/icon.ico + +rsync -av --progress ${CURRENT_DIR}/assets/blue/logo.iconset/icon_128x128.png ${PROJECT_DIST_DIR}/repertory.png diff --git a/project.cmake b/project.cmake index a89eada3..88e2b90d 100644 --- a/project.cmake +++ b/project.cmake @@ -1,7 +1,20 @@ set(CMAKE_CXX_FLAGS "-include common.hpp ${CMAKE_CXX_FLAGS}") +if (PROJECT_IS_DARWIN) + configure_file( + ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist.in + ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Info.plist + @ONLY + ) +endif() + add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}") add_project_executable(${PROJECT_NAME} lib${PROJECT_NAME} lib${PROJECT_NAME}) +if (PROJECT_IS_DARWIN) + set_target_properties(${PROJECT_NAME} PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/Info.plist + ) +endif() add_project_test_executable(${PROJECT_NAME}_test lib${PROJECT_NAME} lib${PROJECT_NAME}) diff --git a/repertory/Info.plist.in b/repertory/Info.plist.in new file mode 100644 index 00000000..81e2d0fb --- /dev/null +++ b/repertory/Info.plist.in @@ -0,0 +1,23 @@ + + + + + CFBundleExecutable + @PROJECT_NAME@ + CFBundleIdentifier + @PROJECT_MACOS_BUNDLE_ID@ + CFBundleName + @PROJECT_NAME@ + CFBundleVersion + @PROJECT_MAJOR_VERSION@.@PROJECT_MINOR_VERSION@.@PROJECT_REVISION_VERSION@-@PROJECT_RELEASE_ITER@_@PROJECT_GIT_REV@ + CFBundleShortVersionString + @PROJECT_MAJOR_VERSION@.@PROJECT_MINOR_VERSION@.@PROJECT_REVISION_VERSION@.@PROJECT_RELEASE_NUM@ + CFBundlePackageType + APPL + LSUIElement + + CFBundleIconFile + @PROJECT_MACOS_ICNS_NAME@ + + diff --git a/repertory/Install repertory.command b/repertory/Install repertory.command new file mode 100644 index 00000000..5e044861 --- /dev/null +++ b/repertory/Install repertory.command @@ -0,0 +1,421 @@ +#!/usr/bin/env bash +# No `-e` (we tolerate benign non-zero returns); keep -Euo +set -Euo pipefail + +LOG_DIR="/tmp" +LOG_FILE="${LOG_DIR}/Install-$(date +%Y%m%d-%H%M%S).log" +exec > >(tee -a "$LOG_FILE") 2>&1 +echo "Logging to: $LOG_FILE" + +TARGET_DIR="/Applications" +APP_NAME="repertory.app" + +# Embedded at pack time (from CFBundleIdentifier prefix) +LABEL_PREFIX="__LABEL_PREFIX__" +UI_LABEL="${LABEL_PREFIX}.ui" + +staged="" +backup="" +snapfile="" +skip_ui_launch=0 + +log() { printf "[%(%H:%M:%S)T] %s\n" -1 "$*"; } +warn() { log "WARN: $*"; } +die() { + log "ERROR: $*" + exit 2 +} + +here="$(cd "$(dirname "$0")" && pwd)" + +# Locate source app on the DMG (supports hidden payload dirs) +src_app="${here}/${APP_NAME}" +if [[ ! -d "$src_app" ]]; then + src_app="$(/usr/bin/find "$here" -type d -name "$APP_NAME" -print -quit 2>/dev/null || true)" +fi +[[ -d "$src_app" ]] || die "Could not find ${APP_NAME} on this disk image." + +app_basename="$(basename "$src_app")" +dest_app="${TARGET_DIR}/${APP_NAME}" + +bundle_id_of() { /usr/bin/defaults read "$1/Contents/Info" CFBundleIdentifier 2>/dev/null || true; } +bundle_exec_of() { /usr/bin/defaults read "$1/Contents/Info" CFBundleExecutable 2>/dev/null || echo "${app_basename%.app}"; } +bundle_version_of() { + /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$1/Contents/Info.plist" 2>/dev/null || + /usr/bin/defaults read "$1/Contents/Info" CFBundleShortVersionString 2>/dev/null || echo "(unknown)" +} +bundle_build_of() { + /usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$1/Contents/Info.plist" 2>/dev/null || + /usr/bin/defaults read "$1/Contents/Info" CFBundleVersion 2>/dev/null || echo "(unknown)" +} + +# Require /Applications; prompt for sudo if needed; abort if cannot elevate +USE_SUDO=0 +SUDO="" +ensure_target_writable() { + if mkdir -p "${TARGET_DIR}/.repertory_install_test.$$" 2>/dev/null; then + rmdir "${TARGET_DIR}/.repertory_install_test.$$" 2>/dev/null || true + USE_SUDO=0 + SUDO="" + return 0 + fi + if command -v sudo >/dev/null 2>&1; then + log "Elevating privileges to write to ${TARGET_DIR}…" + sudo -v || die "Administrator privileges required to install into ${TARGET_DIR}." + USE_SUDO=1 + SUDO="sudo" + return 0 + fi + die "Cannot write to ${TARGET_DIR} and sudo is unavailable." +} + +# ----- STRICT LABEL PREFIX GATE (fail if invalid) ----- +_is_valid_label_prefix() { + local p="${1:-}" + [[ -n "$p" ]] && [[ "$p" != "__LABEL_PREFIX__" ]] && [[ "$p" =~ ^[A-Za-z0-9._-]+$ ]] && [[ "$p" == *.* ]] +} +if ! _is_valid_label_prefix "${LABEL_PREFIX:-}"; then + die "Invalid LABEL_PREFIX in installer (value: \"${LABEL_PREFIX:-}\"). Rebuild the DMG so the installer contains a valid reverse-DNS prefix." +fi + +# ----- LaunchServices helpers ----- +ls_prune_bundle_id() { + local bundle_id="$1" keep_path="$2" + [[ -z "$bundle_id" ]] && return 0 + local search_roots=("/Applications" "$HOME/Applications" "/Volumes") + if [[ -n "${here:-}" && "$here" == /Volumes/* ]]; then search_roots+=("$here"); fi + local candidates="" + for root in "${search_roots[@]}"; do + [[ -d "$root" ]] || continue + candidates+=$'\n'"$(/usr/bin/mdfind -onlyin "$root" "kMDItemCFBundleIdentifier == '${bundle_id}'" 2>/dev/null || true)" + done + # Include backups adjacent to keep_path (quote-safe) + local parent_dir="${keep_path%/*.app}" + candidates+=$'\n'$(/bin/ls -1d "${parent_dir}/"*.bak 2>/dev/null || true) + local LSREG="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister" + printf "%s\n" "$candidates" | /usr/bin/awk 'NF' | /usr/bin/sort -u | while IFS= read -r p; do + [[ -z "$p" || ! -d "$p" || "$p" == "$keep_path" ]] && continue + log "Unregistering older LS entry for ${bundle_id}: $p" + "$LSREG" -u "$p" >/dev/null 2>&1 || true + done +} + +# ----- FUSE unmount (no process killing here) ----- +is_mounted() { /sbin/mount | /usr/bin/awk '{print $3}' | /usr/bin/grep -Fx "${1:-}" >/dev/null 2>&1; } +_list_repertory_fuse_mounts() { /sbin/mount | /usr/bin/grep -Ei 'macfuse|osxfuse' | /usr/bin/awk '{print $3}' | /usr/bin/grep -i "repertory" || true; } +_unmount_one() { + local mnt="${1:-}" + [[ -n "$mnt" ]] || return 0 + /usr/sbin/diskutil unmount "$mnt" >/dev/null 2>&1 || /sbin/umount "$mnt" >/dev/null 2>&1 || true + if is_mounted "$mnt"; then + /usr/sbin/diskutil unmount force "$mnt" >/dev/null 2>&1 || /sbin/umount -f "$mnt" >/dev/null 2>&1 || true + fi + for _ in {1..20}; do + is_mounted "$mnt" || return 0 + sleep 0.25 + done + return 1 +} +unmount_existing_repertory_volumes() { + # Hard-fail on the first unmount problem. + while IFS= read -r mnt; do + [[ -z "$mnt" ]] && continue + log "Unmounting FUSE mount: $mnt" + if ! _unmount_one "$mnt"; then + warn "Failed to unmount $mnt" + return 1 + fi + done < <(_list_repertory_fuse_mounts) + sync || true + sleep 0.3 + return 0 +} + +# ----- user LaunchAgents (by LABEL_PREFIX only) ----- +get_plist_label() { /usr/bin/defaults read "$1" Label 2>/dev/null || /usr/libexec/PlistBuddy -c "Print :Label" "$1" 2>/dev/null || basename "$1" .plist; } + +# Return the executable path a LaunchAgent runs (ProgramArguments[0] or Program). +# Echoes empty string if neither is present. +get_plist_exec_path() { + local plist="$1" arg0="" + # Prefer ProgramArguments[0] + arg0="$(/usr/libexec/PlistBuddy -c 'Print :ProgramArguments:0' "$plist" 2>/dev/null || true)" + if [[ -z "$arg0" ]]; then + # Fallback to Program (older style) + arg0="$(/usr/libexec/PlistBuddy -c 'Print :Program' "$plist" 2>/dev/null || true)" + fi + printf '%s\n' "$arg0" +} + +snapshot_launchagents_user() { + local user_agents="$HOME/Library/LaunchAgents" + snapfile="$(/usr/bin/mktemp "/tmp/repertory_launchagents.XXXXXX")" || snapfile="" + if [[ -z "$snapfile" ]]; then + warn "Could not create temporary snapshot file; skipping LaunchAgent restart snapshot." + return 0 + fi + [[ -d "$user_agents" ]] || return 0 + + # We collect non-UI first, then UI last, to preserve restart order later. + local tmp_nonui tmp_ui + tmp_nonui="$(/usr/bin/mktemp "/tmp/repertory_launchagents.nonui.XXXXXX")" || tmp_nonui="" + tmp_ui="$(/usr/bin/mktemp "/tmp/repertory_launchagents.ui.XXXXXX")" || tmp_ui="" + + /usr/bin/find "$user_agents" -maxdepth 1 -type f -name "${LABEL_PREFIX}"'*.plist' -print 2>/dev/null | + while IFS= read -r plist; do + [[ -z "$plist" ]] && continue + + # Label must match the prefix + local label + label="$(get_plist_label "$plist")" + [[ -n "$label" && "$label" == "${LABEL_PREFIX}"* ]] || continue + + # Executable must point into the *installed* app path + local exec_path + exec_path="$(get_plist_exec_path "$plist")" + [[ -n "$exec_path" ]] || continue + # Normalize: only accept absolute paths under $dest_app (e.g. .../repertory.app/Contents/...) + if [[ "$exec_path" != "$dest_app/"* ]]; then + # Not one of ours; skip + continue + fi + + # Defer UI label to the end + if [[ "$label" == "$UI_LABEL" ]]; then + [[ -n "$tmp_ui" ]] && printf "%s\t%s\n" "$plist" "$label" >>"$tmp_ui" + else + [[ -n "$tmp_nonui" ]] && printf "%s\t%s\n" "$plist" "$label" >>"$tmp_nonui" + fi + done + + # Stitch together: non-UI first, then UI + [[ -s "$tmp_nonui" ]] && /bin/cat "$tmp_nonui" >>"$snapfile" + [[ -s "$tmp_ui" ]] && /bin/cat "$tmp_ui" >>"$snapfile" + + [[ -n "$tmp_nonui" ]] && /bin/rm -f "$tmp_nonui" 2>/dev/null || true + [[ -n "$tmp_ui" ]] && /bin/rm -f "$tmp_ui" 2>/dev/null || true + + log "Snapshot contains $(/usr/bin/wc -l <"$snapfile" 2>/dev/null || echo 0) LaunchAgent(s)." +} + +unload_launchd_helpers_user() { + local uid user_agents + uid="$(id -u)" + user_agents="$HOME/Library/LaunchAgents" + [[ -d "$user_agents" ]] || return 0 + + while IFS= read -r plist; do + [[ -z "$plist" ]] && continue + local base label + base="$(basename "$plist")" + [[ "$base" == "${LABEL_PREFIX}"* ]] || continue + label="$(get_plist_label "$plist")" + [[ -n "$label" && "$label" == "${LABEL_PREFIX}"* ]] || continue + log "Booting out user label ${label} (${plist})" + /bin/launchctl bootout "gui/${uid}" "$plist" 2>/dev/null || + /bin/launchctl bootout "gui/${uid}" "$label" 2>/dev/null || + /bin/launchctl remove "$label" 2>/dev/null || true + done < <(/usr/bin/find "$user_agents" -maxdepth 1 -type f -name "${LABEL_PREFIX}"'*.plist' -print 2>/dev/null) + + /bin/launchctl list 2>/dev/null | /usr/bin/awk -v pre="$LABEL_PREFIX" 'NF>=3 && index($3, pre)==1 {print $3}' | + while read -r lbl; do + [[ -z "$lbl" ]] && continue + log "Booting out leftover user label: $lbl" + /bin/launchctl bootout "gui/${uid}" "$lbl" 2>/dev/null || /bin/launchctl remove "$lbl" 2>/dev/null || true + done +} + +restart_launchagents_from_snapshot() { + [[ -n "${snapfile:-}" && -f "${snapfile}" ]] || return 0 + + local uid count=0 ui_seen=0 + uid="$(id -u)" + + # Pass 1: restart all non-UI agents first + while IFS=$'\t' read -r plist label; do + [[ -n "$plist" && -n "$label" ]] || continue + [[ -f "$plist" ]] || continue + [[ "$label" == "$UI_LABEL" ]] && continue + + log "Re-starting LaunchAgent: ${label}" + /bin/launchctl bootstrap "gui/${uid}" "$plist" 2>/dev/null || true + /bin/launchctl kickstart -k "gui/${uid}/${label}" 2>/dev/null || true + ((count++)) || true + done <"$snapfile" + + # Give helpers a moment to settle (e.g., automounts) + sleep 0.3 + + # Pass 2: restart the UI agent last (if present in the snapshot) + while IFS=$'\t' read -r plist label; do + [[ -n "$plist" && -n "$label" ]] || continue + [[ -f "$plist" ]] || continue + [[ "$label" == "$UI_LABEL" ]] || continue + + log "Re-starting UI LaunchAgent last: ${label}" + /bin/launchctl bootstrap "gui/${uid}" "$plist" 2>/dev/null || true + /bin/launchctl kickstart -k "gui/${uid}/${label}" 2>/dev/null || true + ui_seen=1 + ((count++)) || true + done <"$snapfile" + + log "Re-started ${count} LaunchAgent(s) with prefix ${LABEL_PREFIX}." || true + + if ((ui_seen)); then + # If the UI label is active, skip manual open(1). + if /bin/launchctl list | /usr/bin/awk '{print $3}' | /usr/bin/grep -Fxq "$UI_LABEL"; then + log "UI LaunchAgent (${UI_LABEL}) active after restart; skipping manual UI launch." + skip_ui_launch=1 + fi + fi +} + +# ----- quarantine helper ----- +remove_quarantine() { + local path="${1:-}" + if [[ "${USE_SUDO:-0}" == "1" ]]; then + sudo /usr/bin/xattr -dr com.apple.quarantine "$path" 2>/dev/null || true + else + /usr/bin/xattr -dr com.apple.quarantine "$path" 2>/dev/null || true + fi +} + +# ----- process helpers ----- +kill_repertory_processes() { + local exec_name="$1" + /usr/bin/pkill -TERM -f "$dest_app" >/dev/null 2>&1 || true + /usr/bin/pkill -TERM -x "$exec_name" >/dev/null 2>&1 || true + for _ in {1..20}; do + /usr/bin/pgrep -af "$dest_app" >/dev/null 2>&1 || /usr/bin/pgrep -x "$exec_name" >/dev/null 2>&1 || break + sleep 0.1 + done + /usr/bin/pkill -KILL -f "$dest_app" >/dev/null 2>&1 || true + /usr/bin/pkill -KILL -x "$exec_name" >/dev/null 2>&1 || true +} + +# ----- visibility helper ----- +unhide_path() { + local path="$1" + /usr/bin/chflags -R nohidden "$path" 2>/dev/null || true + /usr/bin/xattr -d -r com.apple.FinderInfo "$path" 2>/dev/null || true +} + +# ----- stage / validate / activate / post-activate ----- +stage_new_app() { + staged="${dest_app}.new-$$" + log "Staging new app → $staged" + $SUDO /usr/bin/ditto "$src_app" "$staged" || die "ditto to stage failed" + remove_quarantine "$staged" +} + +validate_staged_app() { + [[ -f "$staged/Contents/Info.plist" ]] || { + $SUDO /bin/rm -rf "$staged" + die "staged app missing Info.plist" + } + local exe_name_staged + exe_name_staged="$(/usr/bin/defaults read "$staged/Contents/Info" CFBundleExecutable 2>/dev/null || echo "${app_basename%.app}")" + [[ -x "$staged/Contents/MacOS/$exe_name_staged" ]] || { + $SUDO /bin/rm -rf "$staged" + die "staged app missing main executable" + } +} + +activate_staged_app() { + if [[ -d "$dest_app" ]]; then + backup="${dest_app}.$(date +%Y%m%d%H%M%S).bak" + log "Moving existing app to backup: $backup" + $SUDO /bin/mv "$dest_app" "$backup" || { + $SUDO /bin/rm -rf "$staged" + die "failed to move existing app out of the way" + } + fi + log "Activating new app → $dest_app" + if ! $SUDO /bin/mv "$staged" "$dest_app"; then + warn "Activation failed; attempting rollback…" + [[ -n "$backup" && -d "$backup" ]] && $SUDO /bin/mv "$backup" "$dest_app" || true + $SUDO /bin/rm -rf "$staged" || true + die "install activation failed" + fi +} + +post_activate_cleanup() { + log "Clearing quarantine on installed app…" + remove_quarantine "$dest_app" + log "Clearing hidden flags on installed app…" + unhide_path "$dest_app" + + local LSREG="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister" + [[ -x "$LSREG" ]] && "$LSREG" -f "$dest_app" >/dev/null 2>&1 || true + local BID + BID="$(bundle_id_of "$dest_app")" + ls_prune_bundle_id "$BID" "$dest_app" + + log "Installed ${app_basename}: version=$(bundle_version_of "$dest_app") build=$(bundle_build_of "$dest_app")" +} + +launch_ui() { + log "Launching the new app…" + /usr/bin/open -n "$dest_app" || warn "open -n by path failed; not falling back to -b to avoid launching a stale copy." +} + +remove_backup() { + [[ -n "$backup" && -d "$backup" ]] && { + log "Removing backup: $backup" + $SUDO /bin/rm -rf "$backup" || warn "Could not remove backup (safe to delete manually): $backup" + } + log "Done." +} + +cleanup_staged() { + if [[ -n "${staged:-}" && -d "${staged}" ]]; then + log "Cleaning up staged folder: ${staged}" + if [[ "${USE_SUDO:-0}" == "1" ]]; then + sudo /bin/rm -rf "${staged}" 2>/dev/null || true + else + /bin/rm -rf "${staged}" 2>/dev/null || true + fi + fi + if [[ -n "${snapfile:-}" && -f "${snapfile}" ]]; then + /bin/rm -f "${snapfile}" 2>/dev/null || true + fi +} + +main() { + ensure_target_writable + + local exec_name + exec_name="$(bundle_exec_of "$src_app")" + + # 1) Snapshot agents we'll restart later + snapshot_launchagents_user + + # 2) Hard-fail if any FUSE unmount fails + unmount_existing_repertory_volumes || die "One or more FUSE mounts resisted unmount." + + # 3) Stop user LaunchAgents (do NOT delete plists) + unload_launchd_helpers_user + + # 4) Kill any remaining repertory processes + kill_repertory_processes "$exec_name" + + # 5) Stage → validate → activate → post-activate + stage_new_app + validate_staged_app + activate_staged_app + post_activate_cleanup + + # 6) Re-start previously-running LaunchAgents (so automount helpers come up) + restart_launchagents_from_snapshot + + # 7) If UI LaunchAgent came back, skip manual launch + if ((!skip_ui_launch)); then + launch_ui + fi + + # 8) Remove backup now that everything is good + remove_backup +} + +trap 'rc=$?; cleanup_staged; if (( rc != 0 )); then echo "Installer failed with code $rc. See $LOG_FILE"; fi' EXIT +main "$@" diff --git a/repertory/librepertory/include/app_config.hpp b/repertory/librepertory/include/app_config.hpp index db4be5f0..d320109d 100644 --- a/repertory/librepertory/include/app_config.hpp +++ b/repertory/librepertory/include/app_config.hpp @@ -31,24 +31,22 @@ private: static stop_type stop_requested; public: - [[nodiscard]] static auto default_agent_name(const provider_type &prov) + [[nodiscard]] static auto default_agent_name(provider_type prov) -> std::string; - [[nodiscard]] static auto default_api_port(const provider_type &prov) + [[nodiscard]] static auto default_api_port(provider_type prov) -> std::uint16_t; - [[nodiscard]] static auto default_data_directory(const provider_type &prov) + [[nodiscard]] static auto default_data_directory(provider_type prov) -> std::string; - [[nodiscard]] static auto default_remote_api_port(const provider_type &prov) + [[nodiscard]] static auto default_remote_api_port(provider_type prov) -> std::uint16_t; - [[nodiscard]] static auto default_rpc_port() -> std::uint16_t; - - [[nodiscard]] static auto get_provider_display_name(const provider_type &prov) + [[nodiscard]] static auto get_provider_display_name(provider_type prov) -> std::string; - [[nodiscard]] static auto get_provider_name(const provider_type &prov) + [[nodiscard]] static auto get_provider_name(provider_type prov) -> std::string; [[nodiscard]] static auto get_root_data_directory() -> std::string; @@ -59,7 +57,7 @@ public: static void set_stop_requested(); public: - app_config(const provider_type &prov, std::string_view data_directory = ""); + app_config(provider_type prov, std::string_view data_directory); app_config() = delete; app_config(app_config &&) = delete; @@ -72,10 +70,12 @@ public: private: provider_type prov_; - atomic api_password_; + utils::atomic api_password_; std::atomic api_port_; - atomic api_user_; + utils::atomic api_user_; + std::string cache_directory_; std::atomic config_changed_; + std::string data_directory_; std::atomic db_type_{database_type::rocksdb}; std::atomic download_timeout_secs_; std::atomic enable_download_timeout_; @@ -87,6 +87,7 @@ private: std::atomic eviction_delay_mins_; std::atomic eviction_uses_accessed_time_; std::atomic high_freq_interval_secs_; + std::string log_directory_; std::atomic low_freq_interval_secs_; std::atomic max_cache_size_bytes_; std::atomic max_upload_count_; @@ -98,20 +99,16 @@ private: std::atomic task_wait_ms_; private: - std::string cache_directory_; - std::string data_directory_; - atomic encrypt_config_; - atomic host_config_; - std::string log_directory_; + utils::atomic encrypt_config_; + utils::atomic host_config_; mutable std::recursive_mutex read_write_mutex_; - atomic remote_config_; - atomic remote_mount_; - atomic s3_config_; - atomic sia_config_; + utils::atomic remote_config_; + utils::atomic remote_mount_; + utils::atomic s3_config_; + utils::atomic sia_config_; std::unordered_map> value_get_lookup_; - std::unordered_map> + std::unordered_map> value_set_lookup_; std::uint64_t version_{REPERTORY_CONFIG_VERSION}; @@ -121,6 +118,8 @@ private: template auto set_value(dest &dst, const source &src) -> bool; + auto set_value(utils::atomic &dst, std::string_view src) -> bool; + public: [[nodiscard]] auto get_api_password() const -> std::string; @@ -190,21 +189,21 @@ public: [[nodiscard]] auto get_task_wait_ms() const -> std::uint16_t; - [[nodiscard]] auto get_value_by_name(const std::string &name) const + [[nodiscard]] auto get_value_by_name(std::string_view name) const -> std::string; - [[nodiscard]] auto get_raw_value_by_name(const std::string &name) const + [[nodiscard]] auto get_raw_value_by_name(std::string_view name) const -> std::string; [[nodiscard]] auto get_version() const -> std::uint64_t; void save(); - void set_api_password(const std::string &value); + void set_api_password(std::string_view value); void set_api_port(std::uint16_t value); - void set_api_user(const std::string &value); + void set_api_user(std::string_view value); void set_download_timeout_secs(std::uint8_t value); @@ -256,8 +255,8 @@ public: void set_task_wait_ms(std::uint16_t value); - [[nodiscard]] auto set_value_by_name(const std::string &name, - const std::string &value) -> std::string; + [[nodiscard]] auto set_value_by_name(std::string_view name, + std::string_view value) -> std::string; }; } // namespace repertory diff --git a/repertory/librepertory/include/comm/curl/curl_comm.hpp b/repertory/librepertory/include/comm/curl/curl_comm.hpp index 064792f5..d809b1e3 100644 --- a/repertory/librepertory/include/comm/curl/curl_comm.hpp +++ b/repertory/librepertory/include/comm/curl/curl_comm.hpp @@ -43,7 +43,7 @@ private: using write_callback = size_t (*)(char *, size_t, size_t, void *); struct read_write_info final { - data_buffer data{}; + data_buffer data; stop_type_callback stop_requested_cb; }; @@ -62,14 +62,14 @@ public: public: [[nodiscard]] static auto construct_url(CURL *curl, - const std::string &relative_path, + std::string_view relative_path, const host_config &cfg) -> std::string; [[nodiscard]] static auto create_host_config(const s3_config &cfg) -> host_config; - [[nodiscard]] static auto url_encode(CURL *curl, const std::string &data, + [[nodiscard]] static auto url_encode(CURL *curl, std::string_view data, bool allow_slash) -> std::string; template @@ -93,19 +93,19 @@ public: } data_buffer data{}; - const auto key = - utils::encryption::generate_key( - request.decryption_token.value()); + const auto key = utils::encryption::generate_key( + request.decryption_token.value()); if (not utils::encryption::read_encrypted_range( request.range.value(), key, - [&](data_buffer &ct, std::uint64_t start_offset, + [&](data_buffer &buffer, std::uint64_t start_offset, std::uint64_t end_offset) -> bool { auto encrypted_request = request; encrypted_request.decryption_token = std::nullopt; encrypted_request.range = {{start_offset, end_offset}}; encrypted_request.response_handler = - [&ct](const auto &encrypted_data, long /*response_code*/) { - ct = encrypted_data; + [&buffer](const auto &encrypted_data, + long /*response_code*/) { + buffer = encrypted_data; }; encrypted_request.total_size = std::nullopt; diff --git a/repertory/librepertory/include/comm/packet/client_pool.hpp b/repertory/librepertory/include/comm/packet/client_pool.hpp index 9df0ab04..5a5a6837 100644 --- a/repertory/librepertory/include/comm/packet/client_pool.hpp +++ b/repertory/librepertory/include/comm/packet/client_pool.hpp @@ -23,10 +23,13 @@ #define REPERTORY_INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_ #include "comm/packet/packet.hpp" -#include "types/repertory.hpp" namespace repertory { class client_pool final { +public: + static constexpr const std::uint16_t default_expired_seconds{120U}; + static constexpr const std::uint16_t min_expired_seconds{5U}; + public: using worker_callback = std::function; using worker_complete_callback = @@ -46,15 +49,32 @@ private: }; struct work_queue final { + work_queue(); + ~work_queue(); + + work_queue(const work_queue &) = delete; + work_queue(work_queue &&) = delete; + + std::deque> actions; + std::atomic modified{ + std::chrono::steady_clock::now(), + }; std::mutex mutex; std::condition_variable notify; - std::deque> queue; + stop_type shutdown{false}; + std::unique_ptr thread; + + auto operator=(const work_queue &) -> work_queue & = delete; + auto operator=(work_queue &&) -> work_queue & = delete; + + private: + void work_thread(); }; public: - explicit pool(std::uint8_t pool_size); + pool() noexcept = default; - ~pool() { shutdown(); } + ~pool(); public: pool(const pool &) = delete; @@ -63,21 +83,20 @@ private: auto operator=(pool &&) -> pool & = delete; private: - std::vector> pool_queues_; - std::vector pool_threads_; - bool shutdown_{false}; - std::atomic thread_index_{}; + std::mutex pool_mtx_; + std::unordered_map> pool_queues_; public: - void execute(std::uint64_t thread_id, const worker_callback &worker, - const worker_complete_callback &worker_complete); + void execute(std::uint64_t thread_id, worker_callback worker, + worker_complete_callback worker_complete); + + void remove_expired(std::uint16_t seconds); void shutdown(); }; public: - explicit client_pool(std::uint8_t pool_size = min_pool_size) - : pool_size_(pool_size == 0U ? min_pool_size : pool_size) {} + client_pool() noexcept; ~client_pool() { shutdown(); } @@ -88,20 +107,23 @@ public: auto operator=(client_pool &&) -> client_pool & = delete; private: - std::uint8_t pool_size_; - std::unordered_map> pool_lookup_; + std::unordered_map> pool_lookup_; std::mutex pool_mutex_; - bool shutdown_ = false; - -private: - static constexpr auto min_pool_size = 10U; + stop_type shutdown_{false}; + std::atomic expired_seconds_{default_expired_seconds}; public: - void execute(const std::string &client_id, std::uint64_t thread_id, - const worker_callback &worker, - const worker_complete_callback &worker_complete); + [[nodiscard]] auto get_expired_seconds() const -> std::uint16_t; - void remove_client(const std::string &client_id); + void execute(std::string client_id, std::uint64_t thread_id, + worker_callback worker, + worker_complete_callback worker_complete); + + void remove_client(std::string client_id); + + void remove_expired(); + + void set_expired_seconds(std::uint16_t seconds); void shutdown(); }; diff --git a/repertory/librepertory/include/comm/packet/common.hpp b/repertory/librepertory/include/comm/packet/common.hpp new file mode 100644 index 00000000..1ebc6336 --- /dev/null +++ b/repertory/librepertory/include/comm/packet/common.hpp @@ -0,0 +1,54 @@ +/* + Copyright <2018-2025> + + 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 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 REPERTORY_INCLUDE_COMM_PACKET_COMMON_HPP_ +#define REPERTORY_INCLUDE_COMM_PACKET_COMMON_HPP_ + +namespace repertory::comm { +inline static constexpr std::uint32_t max_packet_bytes{32U * 1024U * 1024U}; +inline constexpr const std::uint8_t max_read_attempts{2U}; +inline constexpr const std::uint16_t packet_nonce_size{256U}; +inline constexpr const std::size_t read_write_size{131072U}; +inline constexpr const std::uint16_t server_handshake_timeout_ms{3000U}; + +struct non_blocking_guard final { + non_blocking_guard(const non_blocking_guard &) = delete; + non_blocking_guard(non_blocking_guard &&) = delete; + + auto operator=(const non_blocking_guard &) -> non_blocking_guard & = delete; + auto operator=(non_blocking_guard &&) -> non_blocking_guard & = delete; + + explicit non_blocking_guard(boost::asio::ip::tcp::socket &sock_); + + ~non_blocking_guard(); + +private: + bool non_blocking; + boost::asio::ip::tcp::socket &sock; +}; + +void apply_common_socket_properties(boost::asio::ip::tcp::socket &sock); + +[[nodiscard]] auto is_socket_still_alive(boost::asio::ip::tcp::socket &sock) + -> bool; +} // namespace repertory::comm + +#endif // REPERTORY_INCLUDE_COMM_PACKET_COMMON_HPP_ diff --git a/repertory/librepertory/include/comm/packet/packet.hpp b/repertory/librepertory/include/comm/packet/packet.hpp index 61b5bcbe..32e0ac50 100644 --- a/repertory/librepertory/include/comm/packet/packet.hpp +++ b/repertory/librepertory/include/comm/packet/packet.hpp @@ -200,7 +200,7 @@ public: void encode_top(remote::file_info val); - void encrypt(std::string_view token); + void encrypt(std::string_view token, bool include_size = true); [[nodiscard]] auto get_size() const -> std::uint32_t { return static_cast(buffer_.size()); diff --git a/repertory/librepertory/include/comm/packet/packet_client.hpp b/repertory/librepertory/include/comm/packet/packet_client.hpp index ff47896d..f8569476 100644 --- a/repertory/librepertory/include/comm/packet/packet_client.hpp +++ b/repertory/librepertory/include/comm/packet/packet_client.hpp @@ -1,17 +1,13 @@ /* Copyright <2018-2025> - 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + copies of the Software, and to permit persons 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 + 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 @@ -24,6 +20,7 @@ #include "comm/packet/packet.hpp" #include "types/remote.hpp" +#include "utils/atomic.hpp" using boost::asio::ip::tcp; @@ -47,43 +44,55 @@ public: auto operator=(packet_client &&) -> packet_client & = delete; private: - boost::asio::io_context io_context_; remote::remote_config cfg_; - std::string unique_id_; + mutable boost::asio::io_context io_context_; + utils::atomic unique_id_; private: - bool allow_connections_{true}; - boost::asio::ip::basic_resolver::results_type + std::atomic allow_connections_{true}; + utils::atomic< + boost::asio::ip::basic_resolver::results_type> resolve_results_; std::mutex clients_mutex_; std::vector> clients_; + std::vector service_threads_; private: - static void close(client &cli); + static void close(client &cli) noexcept; void close_all(); - void connect(client &cli); + [[nodiscard]] auto connect(client &cli) -> bool; [[nodiscard]] auto get_client() -> std::shared_ptr; + [[nodiscard]] auto handshake(client &cli, std::uint32_t &min_version) const + -> bool; + void put_client(std::shared_ptr &cli); - [[nodiscard]] auto read_packet(client &cli, - packet &response) const -> packet::error_type; + void read_data(client &cli, data_buffer &buffer) const; + + [[nodiscard]] auto read_packet(client &cli, packet &response) const + -> packet::error_type; void resolve(); + void write_data(client &cli, const packet &request) const; + public: - [[nodiscard]] auto send(std::string_view method, - std::uint32_t &service_flags) -> packet::error_type; + [[nodiscard]] auto check_version(std::uint32_t client_version, + std::uint32_t &min_version) -> api_error; + + [[nodiscard]] auto send(std::string_view method, std::uint32_t &service_flags) + -> packet::error_type; [[nodiscard]] auto send(std::string_view method, packet &request, std::uint32_t &service_flags) -> packet::error_type; [[nodiscard]] auto send(std::string_view method, packet &request, - packet &response, - std::uint32_t &service_flags) -> packet::error_type; + packet &response, std::uint32_t &service_flags) + -> packet::error_type; }; } // namespace repertory diff --git a/repertory/librepertory/include/comm/packet/packet_server.hpp b/repertory/librepertory/include/comm/packet/packet_server.hpp index e81fb1ae..0dc1b38a 100644 --- a/repertory/librepertory/include/comm/packet/packet_server.hpp +++ b/repertory/librepertory/include/comm/packet/packet_server.hpp @@ -23,6 +23,7 @@ #define REPERTORY_INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_ #include "comm/packet/client_pool.hpp" +#include "comm/packet/common.hpp" #include "utils/common.hpp" using namespace boost::asio; @@ -31,11 +32,11 @@ using boost::asio::ip::tcp; namespace repertory { class packet_server final { public: - using closed_callback = std::function; + using closed_callback = std::function; using message_complete_callback = client_pool::worker_complete_callback; - using message_handler_callback = std::function; + using message_handler_callback = + std::function; public: packet_server(std::uint16_t port, std::string token, std::uint8_t pool_size, @@ -61,21 +62,25 @@ private: std::string client_id; std::string nonce; - void generate_nonce() { nonce = utils::generate_random_string(256U); } + void generate_nonce() { + nonce = utils::generate_random_string(comm::packet_nonce_size); + } }; private: std::string encryption_token_; closed_callback closed_; message_handler_callback message_handler_; - io_context io_context_; + mutable io_context io_context_; std::unique_ptr server_thread_; std::vector service_threads_; std::recursive_mutex connection_mutex_; std::unordered_map connection_lookup_; private: - void add_client(connection &conn, const std::string &client_id); + void add_client(connection &conn, std::string client_id); + + [[nodiscard]] auto handshake(std::shared_ptr conn) const -> bool; void initialize(const uint16_t &port, uint8_t pool_size); diff --git a/repertory/librepertory/include/common.hpp b/repertory/librepertory/include/common.hpp index 8c7cb131..2ba70703 100644 --- a/repertory/librepertory/include/common.hpp +++ b/repertory/librepertory/include/common.hpp @@ -22,7 +22,7 @@ #ifndef REPERTORY_INCLUDE_COMMON_HPP_ #define REPERTORY_INCLUDE_COMMON_HPP_ -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(PROJECT_IS_DARWIN) // clang-format off #define REPERTORY_IGNORE_WARNINGS_ENABLE() \ _Pragma("GCC diagnostic push") \ @@ -58,8 +58,8 @@ inline constexpr std::string_view REPERTORY{"repertory"}; inline constexpr std::string_view REPERTORY_DATA_NAME{"repertory2"}; inline constexpr std::wstring_view REPERTORY_W{L"repertory"}; -inline constexpr std::uint64_t REPERTORY_CONFIG_VERSION{2ULL}; -inline constexpr std::string_view REPERTORY_MIN_REMOTE_VERSION{"2.0.0"}; +inline constexpr std::uint64_t REPERTORY_CONFIG_VERSION{5ULL}; +inline constexpr std::string_view REPERTORY_MIN_REMOTE_VERSION{"2.1.0"}; inline constexpr std::string_view RENTERD_MIN_VERSION{"2.0.0"}; #define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE diff --git a/repertory/librepertory/include/db/i_file_db.hpp b/repertory/librepertory/include/db/i_file_db.hpp index ae05c3a3..ac31e731 100644 --- a/repertory/librepertory/include/db/i_file_db.hpp +++ b/repertory/librepertory/include/db/i_file_db.hpp @@ -29,6 +29,13 @@ class i_file_db { INTERFACE_SETUP(i_file_db); public: + struct directory_data final { + std::string api_path; + std::pair + kdf_configs; + std::string source_path; + }; + struct file_info final { std::string api_path; bool directory{}; @@ -40,13 +47,14 @@ public: std::uint64_t file_size{}; std::vector< std::array> - iv_list{}; + iv_list; + std::pair + kdf_configs; std::string source_path; }; public: - [[nodiscard]] virtual auto add_directory(const std::string &api_path, - const std::string &source_path) + [[nodiscard]] virtual auto add_or_update_directory(const directory_data &data) -> api_error = 0; [[nodiscard]] virtual auto add_or_update_file(const file_data &data) @@ -60,39 +68,43 @@ public: std::function &)> callback, stop_type_callback stop_requested_cb) const = 0; - [[nodiscard]] virtual auto get_api_path(const std::string &source_path, + [[nodiscard]] virtual auto get_api_path(std::string_view source_path, std::string &api_path) const -> api_error = 0; [[nodiscard]] virtual auto - get_directory_api_path(const std::string &source_path, + get_directory_api_path(std::string_view source_path, std::string &api_path) const -> api_error = 0; + [[nodiscard]] virtual auto get_directory_data(std::string_view api_path, + directory_data &data) const + -> api_error = 0; + [[nodiscard]] virtual auto - get_directory_source_path(const std::string &api_path, + get_directory_source_path(std::string_view api_path, std::string &source_path) const -> api_error = 0; - [[nodiscard]] virtual auto get_file_api_path(const std::string &source_path, + [[nodiscard]] virtual auto get_file_api_path(std::string_view source_path, std::string &api_path) const -> api_error = 0; - [[nodiscard]] virtual auto get_file_data(const std::string &api_path, + [[nodiscard]] virtual auto get_file_data(std::string_view api_path, file_data &data) const -> api_error = 0; [[nodiscard]] virtual auto - get_file_source_path(const std::string &api_path, + get_file_source_path(std::string_view api_path, std::string &source_path) const -> api_error = 0; [[nodiscard]] virtual auto get_item_list(stop_type_callback stop_requested_cb) const -> std::vector = 0; - [[nodiscard]] virtual auto get_source_path(const std::string &api_path, + [[nodiscard]] virtual auto get_source_path(std::string_view api_path, std::string &source_path) const -> api_error = 0; - [[nodiscard]] virtual auto remove_item(const std::string &api_path) + [[nodiscard]] virtual auto remove_item(std::string_view api_path) -> api_error = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/db/i_file_mgr_db.hpp b/repertory/librepertory/include/db/i_file_mgr_db.hpp index 8d4627f1..e39bc8bc 100644 --- a/repertory/librepertory/include/db/i_file_mgr_db.hpp +++ b/repertory/librepertory/include/db/i_file_mgr_db.hpp @@ -59,23 +59,23 @@ public: [[nodiscard]] virtual auto get_resume_list() const -> std::vector = 0; - [[nodiscard]] virtual auto get_upload(const std::string &api_path) const + [[nodiscard]] virtual auto get_upload(std::string_view api_path) const -> std::optional = 0; [[nodiscard]] virtual auto get_upload_active_list() const -> std::vector = 0; - [[nodiscard]] virtual auto remove_resume(const std::string &api_path) + [[nodiscard]] virtual auto remove_resume(std::string_view api_path) -> bool = 0; - [[nodiscard]] virtual auto remove_upload(const std::string &api_path) + [[nodiscard]] virtual auto remove_upload(std::string_view api_path) -> bool = 0; - [[nodiscard]] virtual auto remove_upload_active(const std::string &api_path) + [[nodiscard]] virtual auto remove_upload_active(std::string_view api_path) -> bool = 0; - [[nodiscard]] virtual auto rename_resume(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] virtual auto rename_resume(std::string_view from_api_path, + std::string_view to_api_path) -> bool = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/db/i_meta_db.hpp b/repertory/librepertory/include/db/i_meta_db.hpp index a1a0d467..1344f7b1 100644 --- a/repertory/librepertory/include/db/i_meta_db.hpp +++ b/repertory/librepertory/include/db/i_meta_db.hpp @@ -35,19 +35,19 @@ public: std::function &)> callback, stop_type_callback stop_requested_cb) const = 0; - [[nodiscard]] virtual auto get_api_path(const std::string &source_path, + [[nodiscard]] virtual auto get_api_path(std::string_view source_path, std::string &api_path) const -> api_error = 0; [[nodiscard]] virtual auto get_api_path_list() const -> std::vector = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, - const std::string &key, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, + std::string_view key, std::string &value) const -> api_error = 0; @@ -58,22 +58,22 @@ public: [[nodiscard]] virtual auto get_total_size() const -> std::uint64_t = 0; - virtual void remove_api_path(const std::string &api_path) = 0; + virtual void remove_api_path(std::string_view api_path) = 0; - [[nodiscard]] virtual auto remove_item_meta(const std::string &api_path, - const std::string &key) + [[nodiscard]] virtual auto remove_item_meta(std::string_view api_path, + std::string_view key) -> api_error = 0; - [[nodiscard]] virtual auto rename_item_meta(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] virtual auto rename_item_meta(std::string_view from_api_path, + std::string_view to_api_path) -> api_error = 0; - [[nodiscard]] virtual auto set_item_meta(const std::string &api_path, - const std::string &key, - const std::string &value) + [[nodiscard]] virtual auto set_item_meta(std::string_view api_path, + std::string_view key, + std::string_view value) -> api_error = 0; - [[nodiscard]] virtual auto set_item_meta(const std::string &api_path, + [[nodiscard]] virtual auto set_item_meta(std::string_view api_path, const api_meta_map &meta) -> api_error = 0; }; diff --git a/repertory/librepertory/include/db/impl/rdb_file_db.hpp b/repertory/librepertory/include/db/impl/rdb_file_db.hpp index 902c777d..c033c6b2 100644 --- a/repertory/librepertory/include/db/impl/rdb_file_db.hpp +++ b/repertory/librepertory/include/db/impl/rdb_file_db.hpp @@ -62,13 +62,12 @@ private: std::function action) -> api_error; - [[nodiscard]] auto remove_item(const std::string &api_path, - const std::string &source_path, + [[nodiscard]] auto remove_item(std::string_view api_path, + std::string_view source_path, rocksdb::Transaction *txn) -> rocksdb::Status; public: - [[nodiscard]] auto add_directory(const std::string &api_path, - const std::string &source_path) + [[nodiscard]] auto add_or_update_directory(const directory_data &data) -> api_error override; [[nodiscard]] auto add_or_update_file(const i_file_db::file_data &data) @@ -82,38 +81,42 @@ public: std::function &)> callback, stop_type_callback stop_requested_cb) const override; - [[nodiscard]] auto get_api_path(const std::string &source_path, + [[nodiscard]] auto get_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; - [[nodiscard]] auto get_directory_api_path(const std::string &source_path, + [[nodiscard]] auto get_directory_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; - [[nodiscard]] auto get_directory_source_path(const std::string &api_path, + [[nodiscard]] auto get_directory_data(std::string_view api_path, + i_file_db::directory_data &data) const + -> api_error override; + + [[nodiscard]] auto get_directory_source_path(std::string_view api_path, std::string &source_path) const -> api_error override; - [[nodiscard]] auto get_file_api_path(const std::string &source_path, + [[nodiscard]] auto get_file_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; - [[nodiscard]] auto get_file_data(const std::string &api_path, + [[nodiscard]] auto get_file_data(std::string_view api_path, i_file_db::file_data &data) const -> api_error override; - [[nodiscard]] auto get_file_source_path(const std::string &api_path, + [[nodiscard]] auto get_file_source_path(std::string_view api_path, std::string &source_path) const -> api_error override; [[nodiscard]] auto get_item_list(stop_type_callback stop_requested_cb) const -> std::vector override; - [[nodiscard]] auto get_source_path(const std::string &api_path, + [[nodiscard]] auto get_source_path(std::string_view api_path, std::string &source_path) const -> api_error override; - [[nodiscard]] auto remove_item(const std::string &api_path) + [[nodiscard]] auto remove_item(std::string_view api_path) -> api_error override; }; } // namespace repertory diff --git a/repertory/librepertory/include/db/impl/rdb_file_mgr_db.hpp b/repertory/librepertory/include/db/impl/rdb_file_mgr_db.hpp index 1e00f9c7..e57a6e0a 100644 --- a/repertory/librepertory/include/db/impl/rdb_file_mgr_db.hpp +++ b/repertory/librepertory/include/db/impl/rdb_file_mgr_db.hpp @@ -61,7 +61,7 @@ private: std::string_view function_name, std::function action) -> bool; - [[nodiscard]] auto remove_resume(const std::string &api_path, + [[nodiscard]] auto remove_resume(std::string_view api_path, rocksdb::Transaction *txn) -> rocksdb::Status; @@ -84,23 +84,21 @@ public: [[nodiscard]] auto get_resume_list() const -> std::vector override; - [[nodiscard]] auto get_upload(const std::string &api_path) const + [[nodiscard]] auto get_upload(std::string_view api_path) const -> std::optional override; [[nodiscard]] auto get_upload_active_list() const -> std::vector override; - [[nodiscard]] auto remove_resume(const std::string &api_path) + [[nodiscard]] auto remove_resume(std::string_view api_path) -> bool override; + + [[nodiscard]] auto remove_upload(std::string_view api_path) -> bool override; + + [[nodiscard]] auto remove_upload_active(std::string_view api_path) -> bool override; - [[nodiscard]] auto remove_upload(const std::string &api_path) - -> bool override; - - [[nodiscard]] auto remove_upload_active(const std::string &api_path) - -> bool override; - - [[nodiscard]] auto rename_resume(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto rename_resume(std::string_view from_api_path, + std::string_view to_api_path) -> bool override; }; diff --git a/repertory/librepertory/include/db/impl/rdb_meta_db.hpp b/repertory/librepertory/include/db/impl/rdb_meta_db.hpp index b235f779..bf78b282 100644 --- a/repertory/librepertory/include/db/impl/rdb_meta_db.hpp +++ b/repertory/librepertory/include/db/impl/rdb_meta_db.hpp @@ -54,7 +54,7 @@ private: void create_or_open(bool clear); - [[nodiscard]] auto get_item_meta_json(const std::string &api_path, + [[nodiscard]] auto get_item_meta_json(std::string_view api_path, json &json_data) const -> api_error; [[nodiscard]] static auto @@ -66,13 +66,12 @@ private: std::function action) -> api_error; - [[nodiscard]] auto remove_api_path(const std::string &api_path, - const std::string &source_path, + [[nodiscard]] auto remove_api_path(std::string_view api_path, + std::string_view source_path, rocksdb::Transaction *txn) -> rocksdb::Status; - [[nodiscard]] auto update_item_meta(const std::string &api_path, - json json_data, + [[nodiscard]] auto update_item_meta(std::string_view api_path, json json_data, rocksdb::Transaction *base_txn = nullptr, rocksdb::Status *status = nullptr) -> api_error; @@ -84,19 +83,19 @@ public: std::function &)> callback, stop_type_callback stop_requested_cb) const override; - [[nodiscard]] auto get_api_path(const std::string &source_path, + [[nodiscard]] auto get_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; [[nodiscard]] auto get_api_path_list() const -> std::vector override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, + [[nodiscard]] auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &key, + [[nodiscard]] auto get_item_meta(std::string_view api_path, + std::string_view key, std::string &value) const -> api_error override; @@ -107,22 +106,21 @@ public: [[nodiscard]] auto get_total_size() const -> std::uint64_t override; - void remove_api_path(const std::string &api_path) override; + void remove_api_path(std::string_view api_path) override; - [[nodiscard]] auto remove_item_meta(const std::string &api_path, - const std::string &key) + [[nodiscard]] auto remove_item_meta(std::string_view api_path, + std::string_view key) -> api_error override; - [[nodiscard]] auto rename_item_meta(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto rename_item_meta(std::string_view from_api_path, + std::string_view to_api_path) -> api_error override; - [[nodiscard]] auto set_item_meta(const std::string &api_path, - const std::string &key, - const std::string &value) + [[nodiscard]] auto set_item_meta(std::string_view api_path, + std::string_view key, std::string_view value) -> api_error override; - [[nodiscard]] auto set_item_meta(const std::string &api_path, + [[nodiscard]] auto set_item_meta(std::string_view api_path, const api_meta_map &meta) -> api_error override; }; diff --git a/repertory/librepertory/include/db/impl/sqlite_file_db.hpp b/repertory/librepertory/include/db/impl/sqlite_file_db.hpp index 4a9a7d82..6c1266ff 100644 --- a/repertory/librepertory/include/db/impl/sqlite_file_db.hpp +++ b/repertory/librepertory/include/db/impl/sqlite_file_db.hpp @@ -42,8 +42,8 @@ private: utils::db::sqlite::db3_t db_; public: - [[nodiscard]] auto add_directory(const std::string &api_path, - const std::string &source_path) + [[nodiscard]] auto + add_or_update_directory(const i_file_db::directory_data &data) -> api_error override; [[nodiscard]] auto add_or_update_file(const i_file_db::file_data &data) @@ -57,38 +57,42 @@ public: std::function &)> callback, stop_type_callback stop_requested_cb) const override; - [[nodiscard]] auto get_api_path(const std::string &source_path, + [[nodiscard]] auto get_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; - [[nodiscard]] auto get_directory_api_path(const std::string &source_path, + [[nodiscard]] auto get_directory_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; - [[nodiscard]] auto get_directory_source_path(const std::string &api_path, + [[nodiscard]] auto get_directory_data(std::string_view api_path, + i_file_db::directory_data &data) const + -> api_error override; + + [[nodiscard]] auto get_directory_source_path(std::string_view api_path, std::string &source_path) const -> api_error override; - [[nodiscard]] auto get_file_api_path(const std::string &source_path, + [[nodiscard]] auto get_file_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; - [[nodiscard]] auto get_file_data(const std::string &api_path, + [[nodiscard]] auto get_file_data(std::string_view api_path, i_file_db::file_data &data) const -> api_error override; - [[nodiscard]] auto get_file_source_path(const std::string &api_path, + [[nodiscard]] auto get_file_source_path(std::string_view api_path, std::string &source_path) const -> api_error override; [[nodiscard]] auto get_item_list(stop_type_callback stop_requested_cb) const -> std::vector override; - [[nodiscard]] auto get_source_path(const std::string &api_path, + [[nodiscard]] auto get_source_path(std::string_view api_path, std::string &source_path) const -> api_error override; - [[nodiscard]] auto remove_item(const std::string &api_path) + [[nodiscard]] auto remove_item(std::string_view api_path) -> api_error override; }; } // namespace repertory diff --git a/repertory/librepertory/include/db/impl/sqlite_file_mgr_db.hpp b/repertory/librepertory/include/db/impl/sqlite_file_mgr_db.hpp index acdb2a1d..b5081491 100644 --- a/repertory/librepertory/include/db/impl/sqlite_file_mgr_db.hpp +++ b/repertory/librepertory/include/db/impl/sqlite_file_mgr_db.hpp @@ -57,23 +57,21 @@ public: [[nodiscard]] auto get_resume_list() const -> std::vector override; - [[nodiscard]] auto get_upload(const std::string &api_path) const + [[nodiscard]] auto get_upload(std::string_view api_path) const -> std::optional override; [[nodiscard]] auto get_upload_active_list() const -> std::vector override; - [[nodiscard]] auto remove_resume(const std::string &api_path) + [[nodiscard]] auto remove_resume(std::string_view api_path) -> bool override; + + [[nodiscard]] auto remove_upload(std::string_view api_path) -> bool override; + + [[nodiscard]] auto remove_upload_active(std::string_view api_path) -> bool override; - [[nodiscard]] auto remove_upload(const std::string &api_path) - -> bool override; - - [[nodiscard]] auto remove_upload_active(const std::string &api_path) - -> bool override; - - [[nodiscard]] auto rename_resume(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto rename_resume(std::string_view from_api_path, + std::string_view to_api_path) -> bool override; }; diff --git a/repertory/librepertory/include/db/impl/sqlite_meta_db.hpp b/repertory/librepertory/include/db/impl/sqlite_meta_db.hpp index c1f7691d..f192e3b5 100644 --- a/repertory/librepertory/include/db/impl/sqlite_meta_db.hpp +++ b/repertory/librepertory/include/db/impl/sqlite_meta_db.hpp @@ -44,7 +44,7 @@ private: constexpr static const auto table_name = "meta"; private: - [[nodiscard]] auto update_item_meta(const std::string &api_path, + [[nodiscard]] auto update_item_meta(std::string_view api_path, api_meta_map meta) -> api_error; public: @@ -54,19 +54,19 @@ public: std::function &)> callback, stop_type_callback stop_requested_cb) const override; - [[nodiscard]] auto get_api_path(const std::string &source_path, + [[nodiscard]] auto get_api_path(std::string_view source_path, std::string &api_path) const -> api_error override; [[nodiscard]] auto get_api_path_list() const -> std::vector override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, + [[nodiscard]] auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &key, + [[nodiscard]] auto get_item_meta(std::string_view api_path, + std::string_view key, std::string &value) const -> api_error override; @@ -77,22 +77,21 @@ public: [[nodiscard]] auto get_total_size() const -> std::uint64_t override; - void remove_api_path(const std::string &api_path) override; + void remove_api_path(std::string_view api_path) override; - [[nodiscard]] auto remove_item_meta(const std::string &api_path, - const std::string &key) + [[nodiscard]] auto remove_item_meta(std::string_view api_path, + std::string_view key) -> api_error override; - [[nodiscard]] auto rename_item_meta(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto rename_item_meta(std::string_view from_api_path, + std::string_view to_api_path) -> api_error override; - [[nodiscard]] auto set_item_meta(const std::string &api_path, - const std::string &key, - const std::string &value) + [[nodiscard]] auto set_item_meta(std::string_view api_path, + std::string_view key, std::string_view value) -> api_error override; - [[nodiscard]] auto set_item_meta(const std::string &api_path, + [[nodiscard]] auto set_item_meta(std::string_view api_path, const api_meta_map &meta) -> api_error override; }; diff --git a/repertory/librepertory/include/drives/directory_cache.hpp b/repertory/librepertory/include/drives/directory_cache.hpp index 1278d5e1..b8abcf42 100644 --- a/repertory/librepertory/include/drives/directory_cache.hpp +++ b/repertory/librepertory/include/drives/directory_cache.hpp @@ -49,18 +49,18 @@ private: std::recursive_mutex directory_mutex_; public: - void execute_action(const std::string &api_path, + void execute_action(std::string_view api_path, const execute_callback &execute); [[nodiscard]] auto get_directory(std::uint64_t handle) -> std::shared_ptr; - auto remove_directory(const std::string &api_path) + auto remove_directory(std::string_view api_path) -> std::shared_ptr; void remove_directory(std::uint64_t handle); - void set_directory(const std::string &api_path, std::uint64_t handle, + void set_directory(std::string_view api_path, std::uint64_t handle, std::shared_ptr iterator); }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/directory_iterator.hpp b/repertory/librepertory/include/drives/directory_iterator.hpp index 372ef86c..00aafedd 100644 --- a/repertory/librepertory/include/drives/directory_iterator.hpp +++ b/repertory/librepertory/include/drives/directory_iterator.hpp @@ -30,8 +30,8 @@ class directory_iterator final { public: #if !defined(_WIN32) using populate_stat_callback = - std::function; + std::function; #endif public: explicit directory_iterator(directory_item_list list) @@ -47,7 +47,7 @@ private: public: #if !defined(_WIN32) - [[nodiscard]] auto fill_buffer(const remote::file_offset &offset, + [[nodiscard]] auto fill_buffer(remote::file_offset offset, fuse_fill_dir_t filler_function, void *buffer, populate_stat_callback populate_stat) -> int; #endif // !defined(_WIN32) @@ -59,13 +59,13 @@ public: [[nodiscard]] auto get_directory_item(std::size_t offset, directory_item &di) -> api_error; - [[nodiscard]] auto get_directory_item(const std::string &api_path, + [[nodiscard]] auto get_directory_item(std::string_view api_path, directory_item &di) -> api_error; [[nodiscard]] auto get_json(std::size_t offset, json &item) -> int; - [[nodiscard]] auto - get_next_directory_offset(const std::string &api_path) const -> std::size_t; + [[nodiscard]] auto get_next_directory_offset(std::string_view api_path) const + -> std::size_t; public: auto operator=(const directory_iterator &iterator) noexcept diff --git a/repertory/librepertory/include/drives/eviction.hpp b/repertory/librepertory/include/drives/eviction.hpp index 0fc48b59..cb8250e7 100644 --- a/repertory/librepertory/include/drives/eviction.hpp +++ b/repertory/librepertory/include/drives/eviction.hpp @@ -46,7 +46,7 @@ private: i_provider &provider_; private: - [[nodiscard]] auto check_minimum_requirements(const std::string &file_path) + [[nodiscard]] auto check_minimum_requirements(std::string_view file_path) -> bool; [[nodiscard]] auto get_filtered_cached_files() -> std::deque; diff --git a/repertory/librepertory/include/drives/fuse/fuse_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_base.hpp index bc0147f3..ca6e1a60 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_base.hpp @@ -52,7 +52,11 @@ private: protected: bool atime_enabled_{true}; - bool console_enabled_{false}; + bool console_enabled_{true}; + bool foreground_{false}; +#if defined(__APPLE__) + std::string label_; +#endif // defined(__APPLE__) std::optional forced_gid_; std::optional forced_uid_; std::optional forced_umask_; @@ -95,50 +99,51 @@ private: #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto chmod_(const char *path, mode_t mode, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto chmod_(const char *path, mode_t mode) -> int; #endif // FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid) -> int; #endif // FUSE_USE_VERSION >= 30 [[nodiscard]] static auto create_(const char *path, mode_t mode, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; static void destroy_(void *ptr); [[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset, - off_t length, struct fuse_file_info *fi) - -> int; + off_t length, + struct fuse_file_info *f_info) -> int; #if FUSE_USE_VERSION < 30 - [[nodiscard]] static auto fgetattr_(const char *path, struct stat *st, - struct fuse_file_info *fi) -> int; + [[nodiscard]] static auto fgetattr_(const char *path, struct stat *u_stat, + struct fuse_file_info *f_info) -> int; #endif // FUSE_USE_VERSION < 30 #if defined(__APPLE__) [[nodiscard]] static auto fsetattr_x_(const char *path, struct setattr_x *attr, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #endif // defined(__APPLE__) [[nodiscard]] static auto fsync_(const char *path, int datasync, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; [[nodiscard]] static auto ftruncate_(const char *path, off_t size, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #if FUSE_USE_VERSION >= 30 - [[nodiscard]] static auto getattr_(const char *path, struct stat *st, - struct fuse_file_info *fi) -> int; + [[nodiscard]] static auto getattr_(const char *path, struct stat *u_stat, + struct fuse_file_info *f_info) -> int; #else // FUSE_USE_VERSION < 30 - [[nodiscard]] static auto getattr_(const char *path, struct stat *st) -> int; + [[nodiscard]] static auto getattr_(const char *path, struct stat *u_stat) + -> int; #endif // FUSE_USE_VERSION >= 30 #if defined(__APPLE__) @@ -154,35 +159,40 @@ private: [[nodiscard]] static auto init_(struct fuse_conn_info *conn) -> void *; #endif // FUSE_USE_VERSION >= 30 + [[nodiscard]] static auto ioctl_(const char *path, int cmd, void *arg, + struct fuse_file_info *f_info, + unsigned int flags, void *data) -> int; + [[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int; - [[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi) - -> int; + [[nodiscard]] static auto open_(const char *path, + struct fuse_file_info *f_info) -> int; [[nodiscard]] static auto opendir_(const char *path, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; [[nodiscard]] static auto read_(const char *path, char *buffer, size_t read_size, off_t read_offset, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto readdir_(const char *path, void *buf, fuse_fill_dir_t fuse_fill_dir, - off_t offset, struct fuse_file_info *fi, + off_t offset, + struct fuse_file_info *f_info, fuse_readdir_flags flags) -> int; #else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto readdir_(const char *path, void *buf, fuse_fill_dir_t fuse_fill_dir, - off_t offset, struct fuse_file_info *fi) - -> int; + off_t offset, + struct fuse_file_info *f_info) -> int; #endif // FUSE_USE_VERSION >= 30 [[nodiscard]] static auto release_(const char *path, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; [[nodiscard]] static auto releasedir_(const char *path, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto rename_(const char *from, const char *to, @@ -248,7 +258,7 @@ private: #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto truncate_(const char *path, off_t size, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto truncate_(const char *path, off_t size) -> int; #endif // FUSE_USE_VERSION >= 30 @@ -258,7 +268,7 @@ private: #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto utimens_(const char *path, const struct timespec tv[2], - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; #else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto utimens_(const char *path, const struct timespec tv[2]) -> int; @@ -266,7 +276,7 @@ private: [[nodiscard]] static auto write_(const char *path, const char *buffer, size_t write_size, off_t write_offset, - struct fuse_file_info *fi) -> int; + struct fuse_file_info *f_info) -> int; protected: [[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/) @@ -284,11 +294,11 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, mode_t /*mode*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } -#else //FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, mode_t /*mode*/) -> api_error { return api_error::not_implemented; @@ -298,11 +308,11 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } -#else // FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/) -> api_error { return api_error::not_implemented; @@ -311,7 +321,7 @@ protected: [[nodiscard]] virtual auto create_impl(std::string /*api_path*/, mode_t /*mode*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } @@ -320,14 +330,14 @@ protected: [[nodiscard]] virtual auto fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/, - off_t /*length*/, struct fuse_file_info * /*fi*/) + off_t /*length*/, struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } [[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/, - struct stat * /*st*/, - struct fuse_file_info * /*fi*/) + struct stat * /*u_stat*/, + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } @@ -335,7 +345,7 @@ protected: #if defined(__APPLE__) [[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } @@ -343,7 +353,7 @@ protected: [[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/, int /*datasync*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } @@ -351,7 +361,7 @@ protected: #if FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/, off_t /*size*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } @@ -359,14 +369,15 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, - struct stat * /*st*/, - struct fuse_file_info * /*fi*/) + struct stat * /*u_stat*/, + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } -#else // FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, - struct stat * /*st*/) -> api_error { + struct stat * /*u_stat*/) + -> api_error { return api_error::not_implemented; } #endif // FUSE_USE_VERSION >= 30 @@ -383,30 +394,37 @@ protected: #if FUSE_USE_VERSION >= 30 virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) -> void *; -#else // FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 virtual auto init_impl(struct fuse_conn_info *conn) -> void *; #endif // FUSE_USE_VERSION >= 30 + [[nodiscard]] virtual auto ioctl_impl(std::string /*api_path*/, int /* cmd */, + void * /* arg */, + struct fuse_file_info * /*f_info*/) + -> api_error { + return api_error::no_tty; + } + [[nodiscard]] virtual auto mkdir_impl(std::string /*api_path*/, mode_t /*mode*/) -> api_error { return api_error::not_implemented; } [[nodiscard]] virtual auto open_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } [[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } [[nodiscard]] virtual auto read_impl(std::string /*api_path*/, char * /*buffer*/, size_t /*read_size*/, - off_t /*read_offset*/, struct fuse_file_info * /*fi*/, + off_t /*read_offset*/, struct fuse_file_info * /*f_info*/, std::size_t & /*bytes_read*/) -> api_error { return api_error::not_implemented; } @@ -415,27 +433,27 @@ protected: [[nodiscard]] virtual auto readdir_impl(std::string /*api_path*/, void * /*buf*/, fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, - struct fuse_file_info * /*fi*/, fuse_readdir_flags /*flags*/) + struct fuse_file_info * /*f_info*/, fuse_readdir_flags /*flags*/) -> api_error { return api_error::not_implemented; } -#else // FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto readdir_impl(std::string /*api_path*/, void * /*buf*/, fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, - struct fuse_file_info * /*fi*/) -> api_error { + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } #endif // FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto release_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } [[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } @@ -446,7 +464,7 @@ protected: unsigned int /*flags*/) -> api_error { return api_error::not_implemented; } -#else // FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/, std::string /*to_api_path*/) -> api_error { @@ -464,14 +482,14 @@ protected: getxattr_impl(std::string /*api_path*/, const char * /*name*/, char * /*value*/, size_t /*size*/, uint32_t /*position*/, int & /*attribute_size*/) -> api_error { - return api_error::not_implemented; + return api_error::xattr_not_found; } #else // !defined(__APPLE__) [[nodiscard]] virtual auto getxattr_impl(std::string /*api_path*/, const char * /*name*/, char * /*value*/, size_t /*size*/, int & /*attribute_size*/) -> api_error { - return api_error::not_implemented; + return api_error::xattr_not_found; } #endif // defined(__APPLE__) @@ -551,11 +569,11 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, off_t /*size*/, - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } -#else // FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, off_t /*size*/) -> api_error { return api_error::not_implemented; @@ -570,11 +588,11 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2], - struct fuse_file_info * /*fi*/) + struct fuse_file_info * /*f_info*/) -> api_error { return api_error::not_implemented; } -#else // FUSE_USE_VERSION < 30 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2]) -> api_error { @@ -585,8 +603,8 @@ protected: [[nodiscard]] virtual auto write_impl(std::string /*api_path*/, const char * /*buffer*/, size_t /*write_size*/, off_t /*write_offset*/, - struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/) - -> api_error { + struct fuse_file_info * /*f_info*/, + std::size_t & /*bytes_written*/) -> api_error { return api_error::not_implemented; } @@ -604,13 +622,15 @@ public: static void display_version_information(std::vector args); - static auto unmount(const std::string &mount_location) -> int; + auto unmount(std::string_view mount_location) -> int; [[nodiscard]] auto get_mount_location() const -> std::string { return mount_location_; } - [[nodiscard]] auto mount(std::vector args) -> int; + [[nodiscard]] auto mount(std::vector orig_args, + std::vector args, provider_type prov, + std::string_view unique_id) -> int; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive.hpp index deb30c47..a2a83922 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive.hpp @@ -67,7 +67,7 @@ private: bool was_mounted_{false}; private: - void update_accessed_time(const std::string &api_path); + void update_accessed_time(std::string_view api_path); void stop_all(); @@ -79,7 +79,7 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #else // FUSE_USE_VERSION < 30 [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) @@ -88,7 +88,7 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #else // FUSE_USE_VERSION < 30 [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) @@ -96,43 +96,43 @@ protected: #endif // FUSE_USE_VERSION >= 30 [[nodiscard]] auto create_impl(std::string api_path, mode_t mode, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; void destroy_impl(void *ptr) override; [[nodiscard]] auto fallocate_impl(std::string api_path, int mode, off_t offset, off_t length, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; - [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *unix_st, - struct fuse_file_info *file_info) + [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *u_stat, + struct fuse_file_info *f_info) -> api_error override; #if defined(__APPLE__) [[nodiscard]] auto fsetattr_x_impl(std::string api_path, struct setattr_x *attr, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #endif // defined(__APPLE__) [[nodiscard]] auto fsync_impl(std::string api_path, int datasync, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #if FUSE_USE_VERSION < 30 [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #endif // FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st, - struct fuse_file_info *file_info) + [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat, + struct fuse_file_info *f_info) -> api_error override; #else // FUSE_USE_VERSION < 30 - [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st) + [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat) -> api_error override; #endif // FUSE_USE_VERSION >= 30 @@ -150,43 +150,47 @@ protected: auto init_impl(struct fuse_conn_info *conn) -> void * override; #endif // FUSE_USE_VERSION >= 30 + [[nodiscard]] auto ioctl_impl(std::string api_path, int cmd, void *arg, + struct fuse_file_info *f_info) + -> api_error override; + [[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode) -> api_error override; void notify_fuse_main_exit(int &ret) override; [[nodiscard]] auto open_impl(std::string api_path, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; [[nodiscard]] auto opendir_impl(std::string api_path, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; [[nodiscard]] auto read_impl(std::string api_path, char *buffer, size_t read_size, off_t read_offset, - struct fuse_file_info *file_info, + struct fuse_file_info *f_info, std::size_t &bytes_read) -> api_error override; #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *file_info, + struct fuse_file_info *f_info, fuse_readdir_flags flags) -> api_error override; #else // FUSE_USE_VERSION < 30 [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #endif // FUSE_USE_VERSION >= 30 [[nodiscard]] auto release_impl(std::string api_path, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; [[nodiscard]] auto releasedir_impl(std::string api_path, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #if FUSE_USE_VERSION >= 30 @@ -262,7 +266,7 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto truncate_impl(std::string api_path, off_t size, - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #else // FUSE_USE_VERSION < 30 [[nodiscard]] auto truncate_impl(std::string api_path, off_t size) @@ -274,7 +278,7 @@ protected: #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto utimens_impl(std::string api_path, const struct timespec tv[2], - struct fuse_file_info *file_info) + struct fuse_file_info *f_info) -> api_error override; #else // FUSE_USE_VERSION < 30 [[nodiscard]] auto utimens_impl(std::string api_path, @@ -284,29 +288,33 @@ protected: [[nodiscard]] auto write_impl(std::string api_path, const char *buffer, size_t write_size, off_t write_offset, - struct fuse_file_info *file_info, + struct fuse_file_info *f_info, std::size_t &bytes_written) -> api_error override; public: - [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const + [[nodiscard]] auto get_directory_item_count(std::string_view api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_directory_items(const std::string &api_path) const + [[nodiscard]] auto get_directory_items(std::string_view api_path) const -> directory_item_list override; - [[nodiscard]] auto get_file_size(const std::string &api_path) const + [[nodiscard]] auto get_file_size(std::string_view api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, + [[nodiscard]] auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &name, + [[nodiscard]] auto get_item_meta(std::string_view api_path, + std::string_view name, std::string &value) const -> api_error override; + [[nodiscard]] auto get_item_stat(std::uint64_t handle, + struct stat64 *u_stat) const + -> api_error override; + [[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override; [[nodiscard]] auto get_total_item_count() const -> std::uint64_t override; @@ -316,21 +324,21 @@ public: void get_volume_info(UINT64 &total_size, UINT64 &free_size, std::string &volume_label) const override; - [[nodiscard]] auto is_processing(const std::string &api_path) const + [[nodiscard]] auto is_processing(std::string_view api_path) const -> bool override; - [[nodiscard]] auto rename_directory(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto rename_directory(std::string_view from_api_path, + std::string_view to_api_path) -> int override; - [[nodiscard]] auto rename_file(const std::string &from_api_path, - const std::string &to_api_path, bool overwrite) + [[nodiscard]] auto rename_file(std::string_view from_api_path, + std::string_view to_api_path, bool overwrite) -> int override; - void set_item_meta(const std::string &api_path, const std::string &key, - const std::string &value) override; + void set_item_meta(std::string_view api_path, std::string_view key, + std::string_view value) override; - void set_item_meta(const std::string &api_path, + void set_item_meta(std::string_view api_path, const api_meta_map &meta) override; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp index 2cc51149..01bbe4ee 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp @@ -47,11 +47,11 @@ protected: -> api_error override; protected: - [[nodiscard]] auto check_access(const std::string &api_path, int mask) const + [[nodiscard]] auto check_access(std::string_view api_path, int mask) const -> api_error; [[nodiscard]] auto - check_and_perform(const std::string &api_path, int parent_mask, + check_and_perform(std::string_view api_path, int parent_mask, const std::function &action) -> api_error; @@ -86,22 +86,21 @@ protected: -> mode_t; static void get_timespec_from_meta(const api_meta_map &meta, - const std::string &name, + std::string_view name, struct timespec &ts); [[nodiscard]] static auto get_uid_from_meta(const api_meta_map &meta) -> uid_t; #if defined(__APPLE__) - [[nodiscard]] auto parse_xattr_parameters(const char *name, - const uint32_t &position, - std::string &attribute_name, - const std::string &api_path) + [[nodiscard]] auto + parse_xattr_parameters(const char *name, const uint32_t &position, + std::string &attribute_name, std::string_view api_path) -> api_error; #else // !defined(__APPLE__) [[nodiscard]] auto parse_xattr_parameters(const char *name, std::string &attribute_name, - const std::string &api_path) + std::string_view api_path) -> api_error; #endif // defined(__APPLE__) @@ -109,30 +108,31 @@ protected: [[nodiscard]] auto parse_xattr_parameters(const char *name, const char *value, size_t size, const uint32_t &position, std::string &attribute_name, - const std::string &api_path) -> api_error; + std::string_view api_path) -> api_error; #else // !defined(__APPLE__) - [[nodiscard]] auto parse_xattr_parameters(const char *name, const char *value, - size_t size, - std::string &attribute_name, - const std::string &api_path) + [[nodiscard]] auto + parse_xattr_parameters(const char *name, const char *value, size_t size, + std::string &attribute_name, std::string_view api_path) -> api_error; #endif // defined(__APPLE__) - static void populate_stat(const std::string &api_path, + static void populate_stat(std::string_view api_path, std::uint64_t size_or_count, const api_meta_map &meta, bool directory, - i_provider &provider, struct stat *st); + i_provider &provider, struct stat *u_stat); static void set_timespec_from_meta(const api_meta_map &meta, - const std::string &name, + std::string_view name, struct timespec &ts); public: - [[nodiscard]] auto check_owner(const std::string &api_path) const + [[nodiscard]] auto check_owner(std::string_view api_path) const -> api_error override; - [[nodiscard]] auto check_parent_access(const std::string &api_path, + [[nodiscard]] auto check_parent_access(std::string_view api_path, int mask) const -> api_error override; + + [[nodiscard]] static auto validate_timespec(const timespec &spec) -> bool; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp index e70624f7..106f29e0 100644 --- a/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp @@ -26,37 +26,43 @@ #include "types/repertory.hpp" namespace repertory { +inline constexpr const int repertory_ioctl_fd_command = 0x102010; + class i_fuse_drive { INTERFACE_SETUP(i_fuse_drive); public: - [[nodiscard]] virtual auto check_owner(const std::string &api_path) const + [[nodiscard]] virtual auto check_owner(std::string_view api_path) const -> api_error = 0; - [[nodiscard]] virtual auto check_parent_access(const std::string &api_path, + [[nodiscard]] virtual auto check_parent_access(std::string_view api_path, int mask) const -> api_error = 0; [[nodiscard]] virtual auto - get_directory_item_count(const std::string &api_path) const + get_directory_item_count(std::string_view api_path) const -> std::uint64_t = 0; [[nodiscard]] virtual auto - get_directory_items(const std::string &api_path) const + get_directory_items(std::string_view api_path) const -> directory_item_list = 0; - [[nodiscard]] virtual auto get_file_size(const std::string &api_path) const + [[nodiscard]] virtual auto get_file_size(std::string_view api_path) const -> std::uint64_t = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, - const std::string &name, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, + std::string_view name, std::string &value) const -> api_error = 0; + [[nodiscard]] virtual auto get_item_stat(std::uint64_t handle, + struct stat64 *u_stat) const + -> api_error = 0; + [[nodiscard]] virtual auto get_total_drive_space() const -> std::uint64_t = 0; [[nodiscard]] virtual auto get_total_item_count() const -> std::uint64_t = 0; @@ -66,22 +72,21 @@ public: virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size, std::string &volume_label) const = 0; - [[nodiscard]] virtual auto is_processing(const std::string &api_path) const + [[nodiscard]] virtual auto is_processing(std::string_view api_path) const -> bool = 0; - [[nodiscard]] virtual auto rename_directory(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] virtual auto rename_directory(std::string_view from_api_path, + std::string_view to_api_path) -> int = 0; - [[nodiscard]] virtual auto rename_file(const std::string &from_api_path, - const std::string &to_api_path, + [[nodiscard]] virtual auto rename_file(std::string_view from_api_path, + std::string_view to_api_path, bool overwrite) -> int = 0; - virtual void set_item_meta(const std::string &api_path, - const std::string &key, - const std::string &value) = 0; + virtual void set_item_meta(std::string_view api_path, std::string_view key, + std::string_view value) = 0; - virtual void set_item_meta(const std::string &api_path, + virtual void set_item_meta(std::string_view api_path, const api_meta_map &meta) = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/i_remote_instance.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/i_remote_instance.hpp index 4999da86..68bbcd1d 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/i_remote_instance.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/i_remote_instance.hpp @@ -30,166 +30,170 @@ class i_remote_instance : public virtual i_remote_json { INTERFACE_SETUP(i_remote_instance); public: - [[nodiscard]] virtual auto - fuse_access(const char *path, - const std::int32_t &mask) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_access(const char *path, std::int32_t mask) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_chflags(const char *path, std::uint32_t flags) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_chmod(const char *path, + remote::file_mode mode) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_chown(const char *path, remote::user_id uid, + remote::group_id gid) + -> packet::error_type = 0; [[nodiscard]] virtual auto - fuse_chflags(const char *path, std::uint32_t flags) -> packet::error_type = 0; + fuse_create(const char *path, remote::file_mode mode, + const remote::open_flags &flags, remote::file_handle &handle) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_chmod(const char *path, - const remote::file_mode &mode) -> packet::error_type = 0; - - [[nodiscard]] virtual auto - fuse_chown(const char *path, const remote::user_id &uid, - const remote::group_id &gid) -> packet::error_type = 0; - - [[nodiscard]] virtual auto - fuse_create(const char *path, const remote::file_mode &mode, - const remote::open_flags &flags, - remote::file_handle &handle) -> packet::error_type = 0; [[nodiscard]] virtual auto fuse_destroy() -> packet::error_type = 0; /*[[nodiscard]] virtual packet::error_type fuse_fallocate(const char *path, - const std::int32_t &mode, const remote::file_offset &offset, const - remote::file_offset &length, const remote::file_offset &length, const - remote::file_handle &handle) = 0;*/ + std::int32_t mode, remote::file_offset offset, const + remote::file_offset length, remote::file_offset length, const + remote::file_handle handle) = 0;*/ [[nodiscard]] virtual auto fuse_fgetattr(const char *path, remote::stat &r_stat, bool &directory, - const remote::file_handle &handle) -> packet::error_type = 0; + remote::file_handle handle) -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_fsetattr_x(const char *path, const remote::setattr_x &attr, - const remote::file_handle &handle) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_fsetattr_x(const char *path, + const remote::setattr_x &attr, + remote::file_handle handle) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_fsync(const char *path, const std::int32_t &datasync, - const remote::file_handle &handle) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_fsync(const char *path, std::int32_t datasync, + remote::file_handle handle) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_ftruncate(const char *path, const remote::file_offset &size, - const remote::file_handle &handle) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_ftruncate(const char *path, + remote::file_offset size, + remote::file_handle handle) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_getattr(const char *path, remote::stat &r_stat, - bool &directory) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_getattr(const char *path, + remote::stat &r_stat, bool &directory) + -> packet::error_type = 0; /*[[nodiscard]] virtual packet::error_type fuse_getxattr(const char *path, - const char *name, char *value, const remote::file_size &size) = 0; + const char *name, char *value, remote::file_size size) = 0; [[nodiscard]] virtual packet::error_type fuse_getxattrOSX(const char *path, - const char *name, char *value, const remote::file_size &size, std::uint32_t + const char *name, char *value, remote::file_size size, std::uint32_t position) = 0;*/ - [[nodiscard]] virtual auto - fuse_getxtimes(const char *path, remote::file_time &bkuptime, - remote::file_time &crtime) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_getxtimes(const char *path, + remote::file_time &bkuptime, + remote::file_time &crtime) + -> packet::error_type = 0; [[nodiscard]] virtual auto fuse_init() -> packet::error_type = 0; [[nodiscard]] /*virtual packet::error_type fuse_listxattr(const char *path, - char *buffer, const remote::file_size &size) = 0;*/ + char *buffer, remote::file_size size) = 0;*/ [[nodiscard]] virtual auto - fuse_mkdir(const char *path, - const remote::file_mode &mode) -> packet::error_type = 0; + fuse_mkdir(const char *path, remote::file_mode mode) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_open(const char *path, + const remote::open_flags &flags, + remote::file_handle &handle) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_opendir(const char *path, + remote::file_handle &handle) + -> packet::error_type = 0; [[nodiscard]] virtual auto - fuse_open(const char *path, const remote::open_flags &flags, - remote::file_handle &handle) -> packet::error_type = 0; + fuse_read(const char *path, char *buffer, remote::file_size read_size, + remote::file_offset read_offset, remote::file_handle handle) + -> packet::error_type = 0; [[nodiscard]] virtual auto - fuse_opendir(const char *path, - remote::file_handle &handle) -> packet::error_type = 0; + fuse_readdir(const char *path, remote::file_offset offset, + remote::file_handle handle, std::string &item_path) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_read(const char *path, char *buffer, const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_release(const char *path, + remote::file_handle handle) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_readdir(const char *path, const remote::file_offset &offset, - const remote::file_handle &handle, - std::string &item_path) -> packet::error_type = 0; - - [[nodiscard]] virtual auto - fuse_release(const char *path, - const remote::file_handle &handle) -> packet::error_type = 0; - - [[nodiscard]] virtual auto - fuse_releasedir(const char *path, - const remote::file_handle &handle) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_releasedir(const char *path, + remote::file_handle handle) + -> packet::error_type = 0; //[[nodiscard]] virtual packet::error_type fuse_removexattr(const char *path, // const char *name) = // 0; - [[nodiscard]] virtual auto - fuse_rename(const char *from, const char *to) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_rename(const char *from, const char *to) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_rmdir(const char *path) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_rmdir(const char *path) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_setattr_x(const char *path, - remote::setattr_x &attr) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_setattr_x(const char *path, + remote::setattr_x &attr) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_setbkuptime(const char *path, - const remote::file_time &bkuptime) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_setbkuptime(const char *path, + remote::file_time bkuptime) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_setchgtime(const char *path, - const remote::file_time &chgtime) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_setchgtime(const char *path, + remote::file_time chgtime) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_setcrtime(const char *path, - const remote::file_time &crtime) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_setcrtime(const char *path, + remote::file_time crtime) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_setvolname(const char *volname) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_setvolname(const char *volname) + -> packet::error_type = 0; /*[[nodiscard]] virtual packet::error_type fuse_setxattr(const char *path, - const char *name, const char *value, const remote::file_size &size, const + const char *name, const char *value, remote::file_size size, const std::int32_t &flags) = 0; [[nodiscard]] virtual packet::error_type fuse_setxattr_osx(const char *path, - const char *name, const char *value, const remote::file_size &size, const + const char *name, const char *value, remote::file_size size, const std::int32_t &flags, std::uint32_t position) = 0;*/ - [[nodiscard]] virtual auto - fuse_statfs(const char *path, std::uint64_t frsize, - remote::statfs &r_stat) -> packet::error_type = 0; + [[nodiscard]] virtual auto fuse_statfs(const char *path, std::uint64_t frsize, + remote::statfs &r_stat) + -> packet::error_type = 0; [[nodiscard]] virtual auto - fuse_statfs_x(const char *path, std::uint64_t bsize, - remote::statfs_x &r_stat) -> packet::error_type = 0; + fuse_statfs_x(const char *path, std::uint64_t bsize, remote::statfs_x &r_stat) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_truncate(const char *path, + remote::file_offset size) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_unlink(const char *path) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto fuse_utimens(const char *path, + const remote::file_time *tv, + std::uint64_t op0, std::uint64_t op1) + -> packet::error_type = 0; [[nodiscard]] virtual auto - fuse_truncate(const char *path, - const remote::file_offset &size) -> packet::error_type = 0; + fuse_write(const char *path, const char *buffer, remote::file_size writeSize, + remote::file_offset writeOffset, remote::file_handle handle) + -> packet::error_type = 0; [[nodiscard]] virtual auto - fuse_unlink(const char *path) -> packet::error_type = 0; + fuse_write_base64(const char *path, const char *buffer, + remote::file_size writeSize, + remote::file_offset writeOffset, remote::file_handle handle) + -> packet::error_type = 0; - [[nodiscard]] virtual auto - fuse_utimens(const char *path, const remote::file_time *tv, std::uint64_t op0, - std::uint64_t op1) -> packet::error_type = 0; - - [[nodiscard]] virtual auto - fuse_write(const char *path, const char *buffer, - const remote::file_size &writeSize, - const remote::file_offset &writeOffset, - const remote::file_handle &handle) -> packet::error_type = 0; - - [[nodiscard]] virtual auto fuse_write_base64( - const char *path, const char *buffer, const remote::file_size &writeSize, - const remote::file_offset &writeOffset, - const remote::file_handle &handle) -> packet::error_type = 0; - - virtual void set_fuse_uid_gid(const remote::user_id &uid, - const remote::group_id &gid) = 0; + virtual void set_fuse_uid_gid(remote::user_id uid, remote::group_id gid) = 0; }; using remote_instance_factory = diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp index 63495069..6f040940 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp @@ -24,7 +24,6 @@ #include "comm/packet/packet_client.hpp" #include "drives/fuse/remotefuse/i_remote_instance.hpp" -#include "events/event_system.hpp" #include "types/remote.hpp" namespace repertory { @@ -44,54 +43,52 @@ private: public: [[nodiscard]] auto check() -> packet::error_type; - [[nodiscard]] auto fuse_access(const char *path, const std::int32_t &mask) + [[nodiscard]] auto fuse_access(const char *path, std::int32_t mask) -> packet::error_type override; [[nodiscard]] auto fuse_chflags(const char *path, std::uint32_t flags) -> packet::error_type override; - [[nodiscard]] auto fuse_chmod(const char *path, const remote::file_mode &mode) + [[nodiscard]] auto fuse_chmod(const char *path, remote::file_mode mode) -> packet::error_type override; - [[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid, - const remote::group_id &gid) + [[nodiscard]] auto fuse_chown(const char *path, remote::user_id uid, + remote::group_id gid) -> packet::error_type override; [[nodiscard]] auto fuse_destroy() -> packet::error_type override; [[nodiscard]] /*packet::error_type fuse_fallocate(const char *path, const - std::int32_t &mode, const remote::file_offset &offset, const - remote::file_offset &length, const remote::file_handle + std::int32_t &mode, remote::file_offset offset, const + remote::file_offset length, const remote::file_handle &handle) override ;*/ [[nodiscard]] auto - fuse_fgetattr(const char *path, remote::stat &st, bool &directory, - const remote::file_handle &handle) - -> packet::error_type override; + fuse_fgetattr(const char *path, remote::stat &r_stat, bool &directory, + remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_fsetattr_x(const char *path, const remote::setattr_x &attr, - const remote::file_handle &handle) + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto fuse_fsync(const char *path, const std::int32_t &datasync, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_fsync(const char *path, std::int32_t datasync, + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto fuse_ftruncate(const char *path, - const remote::file_offset &size, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_ftruncate(const char *path, remote::file_offset size, + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &st, + [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &r_stat, bool &directory) -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_getxattr(const char *path, const char - *name, char *value, const remote::file_size &size) override ; + *name, char *value, remote::file_size size) override ; [[nodiscard]] packet::error_type fuse_getxattrOSX(const char *path, const char - *name, char *value, const remote::file_size &size, std::uint32_t position) + *name, char *value, remote::file_size size, std::uint32_t position) override ;*/ [[nodiscard]] auto fuse_getxtimes(const char *path, @@ -102,17 +99,17 @@ public: [[nodiscard]] auto fuse_init() -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_listxattr(const char *path, char - *buffer, const remote::file_size &size) override ;*/ + *buffer, remote::file_size size) override ;*/ - [[nodiscard]] auto fuse_mkdir(const char *path, const remote::file_mode &mode) + [[nodiscard]] auto fuse_mkdir(const char *path, remote::file_mode mode) -> packet::error_type override; [[nodiscard]] auto fuse_opendir(const char *path, remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto - fuse_create(const char *path, const remote::file_mode &mode, - const remote::open_flags &flags, remote::file_handle &handle) + [[nodiscard]] auto fuse_create(const char *path, remote::file_mode mode, + const remote::open_flags &flags, + remote::file_handle &handle) -> packet::error_type override; [[nodiscard]] auto fuse_open(const char *path, @@ -120,26 +117,24 @@ public: remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_read(const char *path, char *buffer, - const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) + [[nodiscard]] auto + fuse_read(const char *path, char *buffer, remote::file_size read_size, + remote::file_offset read_offset, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_rename(const char *from, const char *to) -> packet::error_type override; - [[nodiscard]] auto - fuse_readdir(const char *path, const remote::file_offset &offset, - const remote::file_handle &handle, std::string &item_path) + [[nodiscard]] auto fuse_readdir(const char *path, remote::file_offset offset, + remote::file_handle handle, + std::string &item_path) -> packet::error_type override; - [[nodiscard]] auto fuse_release(const char *path, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_release(const char *path, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_releasedir(const char *path, - const remote::file_handle &handle) + remote::file_handle handle) -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_removexattr(const char *path, const @@ -153,38 +148,36 @@ public: -> packet::error_type override; [[nodiscard]] auto fuse_setbkuptime(const char *path, - const remote::file_time &bkuptime) + remote::file_time bkuptime) -> packet::error_type override; [[nodiscard]] auto fuse_setchgtime(const char *path, - const remote::file_time &chgtime) + remote::file_time chgtime) -> packet::error_type override; - [[nodiscard]] auto fuse_setcrtime(const char *path, - const remote::file_time &crtime) + [[nodiscard]] auto fuse_setcrtime(const char *path, remote::file_time crtime) -> packet::error_type override; [[nodiscard]] auto fuse_setvolname(const char *volname) -> packet::error_type override; [[nodiscard]] /*packet::error_type fuse_setxattr(const char *path, const char - *name, const char *value, const remote::file_size &size, const std::int32_t + *name, const char *value, remote::file_size size, const std::int32_t &flags) override ; [[nodiscard]] packet::error_type fuse_setxattr_osx(const char *path, const - char *name, const char *value, const remote::file_size &size, const + char *name, const char *value, remote::file_size size, const std::int32_t &flags, std::uint32_t position) override ;*/ [[nodiscard]] auto - fuse_statfs(const char *path, std::uint64_t frsize, remote::statfs &st) + fuse_statfs(const char *path, std::uint64_t frsize, remote::statfs &r_stat) -> packet::error_type override; [[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize, - remote::statfs_x &st) + remote::statfs_x &r_stat) -> packet::error_type override; - [[nodiscard]] auto fuse_truncate(const char *path, - const remote::file_offset &size) + [[nodiscard]] auto fuse_truncate(const char *path, remote::file_offset size) -> packet::error_type override; [[nodiscard]] auto fuse_unlink(const char *path) @@ -194,33 +187,32 @@ public: std::uint64_t op0, std::uint64_t op1) -> packet::error_type override; - [[nodiscard]] auto fuse_write(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) + [[nodiscard]] auto + fuse_write(const char *path, const char *buffer, remote::file_size write_size, + remote::file_offset write_offset, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) + remote::file_size write_size, + remote::file_offset write_offset, + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto json_create_directory_snapshot(const std::string &path, + [[nodiscard]] auto json_create_directory_snapshot(std::string_view path, json &json_data) -> packet::error_type override; - [[nodiscard]] auto json_read_directory_snapshot( - const std::string &path, const remote::file_handle &handle, - std::uint32_t page, json &json_data) -> packet::error_type override; - - [[nodiscard]] auto - json_release_directory_snapshot(const std::string &path, - const remote::file_handle &handle) + [[nodiscard]] auto json_read_directory_snapshot(std::string_view path, + remote::file_handle handle, + std::uint32_t page, + json &json_data) -> packet::error_type override; - void set_fuse_uid_gid(const remote::user_id &uid, - const remote::group_id &gid) override; + [[nodiscard]] auto json_release_directory_snapshot(std::string_view path, + remote::file_handle handle) + -> packet::error_type override; + + void set_fuse_uid_gid(remote::user_id uid, remote::group_id gid) override; }; } // namespace remote_fuse } // namespace repertory diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp index aef87cc2..d91c25ec 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp @@ -25,7 +25,6 @@ #include "drives/fuse/fuse_base.hpp" #include "drives/fuse/remotefuse/i_remote_instance.hpp" -#include "events/event_system.hpp" namespace repertory { class app_config; @@ -40,6 +39,11 @@ public: remote_fuse_drive(app_config &config, remote_instance_factory factory, lock_data &lock) : fuse_base(config), factory_(std::move(factory)), lock_data_(lock) {} + remote_fuse_drive(const remote_fuse_drive &) = delete; + remote_fuse_drive(remote_fuse_drive &&) = delete; + + auto operator=(const remote_fuse_drive &) -> remote_fuse_drive & = delete; + auto operator=(remote_fuse_drive &&) -> remote_fuse_drive & = delete; ~remote_fuse_drive() override = default; @@ -54,95 +58,97 @@ private: private: static void populate_stat(const remote::stat &r_stat, bool directory, - struct stat &unix_st); + struct stat &u_stat); protected: - [[nodiscard]] auto access_impl(std::string api_path, - int mask) -> api_error override; + [[nodiscard]] auto access_impl(std::string api_path, int mask) + -> api_error override; #if defined(__APPLE__) - [[nodiscard]] auto chflags_impl(std::string api_path, - uint32_t flags) -> api_error override; + [[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags) + -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto - chmod_impl(std::string api_path, mode_t mode, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, + struct fuse_file_info *f_info) + -> api_error override; #else - [[nodiscard]] auto chmod_impl(std::string api_path, - mode_t mode) -> api_error override; + [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) + -> api_error override; #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto - chown_impl(std::string api_path, uid_t uid, gid_t gid, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, + struct fuse_file_info *f_info) + -> api_error override; #else - [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, - gid_t gid) -> api_error override; + [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) + -> api_error override; #endif - [[nodiscard]] auto - create_impl(std::string api_path, mode_t mode, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto create_impl(std::string api_path, mode_t mode, + struct fuse_file_info *f_info) + -> api_error override; void destroy_impl(void * /*ptr*/) override; - [[nodiscard]] auto - fgetattr_impl(std::string api_path, struct stat *unix_st, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *u_stat, + struct fuse_file_info *f_info) + -> api_error override; #if defined(__APPLE__) - [[nodiscard]] auto - fsetattr_x_impl(std::string api_path, struct setattr_x *attr, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto fsetattr_x_impl(std::string api_path, + struct setattr_x *attr, + struct fuse_file_info *f_info) + -> api_error override; #endif // __APPLE__ - [[nodiscard]] auto - fsync_impl(std::string api_path, int datasync, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto fsync_impl(std::string api_path, int datasync, + struct fuse_file_info *f_info) + -> api_error override; #if FUSE_USE_VERSION < 30 - [[nodiscard]] auto - ftruncate_impl(std::string api_path, off_t size, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, + struct fuse_file_info *f_info) + -> api_error override; #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto - getattr_impl(std::string api_path, struct stat *unix_st, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat, + struct fuse_file_info *f_info) + -> api_error override; #else - [[nodiscard]] auto getattr_impl(std::string api_path, - struct stat *unix_st) -> api_error override; + [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat) + -> api_error override; #endif #if defined(__APPLE__) - [[nodiscard]] auto - getxtimes_impl(std::string api_path, struct timespec *bkuptime, - struct timespec *crtime) -> api_error override; + [[nodiscard]] auto getxtimes_impl(std::string api_path, + struct timespec *bkuptime, + struct timespec *crtime) + -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - auto init_impl(struct fuse_conn_info *conn, - struct fuse_config *cfg) -> void * override; + auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) + -> void * override; #else auto init_impl(struct fuse_conn_info *conn) -> void * override; #endif - [[nodiscard]] auto mkdir_impl(std::string api_path, - mode_t mode) -> api_error override; + [[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode) + -> api_error override; void notify_fuse_main_exit(int &ret) override; - [[nodiscard]] auto - open_impl(std::string api_path, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto open_impl(std::string api_path, + struct fuse_file_info *f_info) + -> api_error override; - [[nodiscard]] auto - opendir_impl(std::string api_path, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto opendir_impl(std::string api_path, + struct fuse_file_info *f_info) + -> api_error override; [[nodiscard]] auto read_impl(std::string api_path, char *buffer, size_t read_size, off_t read_offset, @@ -150,29 +156,30 @@ protected: std::size_t &bytes_read) -> api_error override; #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto - readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, - off_t offset, struct fuse_file_info *f_info, - fuse_readdir_flags flags) -> api_error override; + [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, + fuse_fill_dir_t fuse_fill_dir, off_t offset, + struct fuse_file_info *f_info, + fuse_readdir_flags flags) + -> api_error override; #else - [[nodiscard]] auto - readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, - off_t offset, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, + fuse_fill_dir_t fuse_fill_dir, off_t offset, + struct fuse_file_info *f_info) + -> api_error override; #endif - [[nodiscard]] auto - release_impl(std::string api_path, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto release_impl(std::string api_path, + struct fuse_file_info *f_info) + -> api_error override; - [[nodiscard]] auto - releasedir_impl(std::string api_path, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto releasedir_impl(std::string api_path, + struct fuse_file_info *f_info) + -> api_error override; #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto rename_impl(std::string from_api_path, - std::string to_api_path, - unsigned int flags) -> api_error override; + std::string to_api_path, unsigned int flags) + -> api_error override; #else [[nodiscard]] auto rename_impl(std::string from_api_path, std::string to_api_path) -> api_error override; @@ -181,58 +188,60 @@ protected: [[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override; #if defined(__APPLE__) - [[nodiscard]] auto - setattr_x_impl(std::string api_path, - struct setattr_x *attr) -> api_error override; + [[nodiscard]] auto setattr_x_impl(std::string api_path, + struct setattr_x *attr) + -> api_error override; - [[nodiscard]] auto - setbkuptime_impl(std::string api_path, - const struct timespec *bkuptime) -> api_error override; + [[nodiscard]] auto setbkuptime_impl(std::string api_path, + const struct timespec *bkuptime) + -> api_error override; - [[nodiscard]] auto - setchgtime_impl(std::string api_path, - const struct timespec *chgtime) -> api_error override; + [[nodiscard]] auto setchgtime_impl(std::string api_path, + const struct timespec *chgtime) + -> api_error override; - [[nodiscard]] auto - setcrtime_impl(std::string api_path, - const struct timespec *crtime) -> api_error override; + [[nodiscard]] auto setcrtime_impl(std::string api_path, + const struct timespec *crtime) + -> api_error override; - [[nodiscard]] virtual auto - setvolname_impl(const char *volname) -> api_error override; + [[nodiscard]] virtual auto setvolname_impl(const char *volname) + -> api_error override; - [[nodiscard]] auto statfs_x_impl(std::string api_path, - struct statfs *stbuf) -> api_error override; + [[nodiscard]] auto statfs_x_impl(std::string api_path, struct statfs *stbuf) + -> api_error override; #else // __APPLE__ - [[nodiscard]] auto statfs_impl(std::string api_path, - struct statvfs *stbuf) -> api_error override; + [[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf) + -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto - truncate_impl(std::string api_path, off_t size, - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto truncate_impl(std::string api_path, off_t size, + struct fuse_file_info *f_info) + -> api_error override; #else - [[nodiscard]] auto truncate_impl(std::string api_path, - off_t size) -> api_error override; + [[nodiscard]] auto truncate_impl(std::string api_path, off_t size) + -> api_error override; #endif [[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override; #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto - utimens_impl(std::string api_path, const struct timespec tv[2], - struct fuse_file_info *f_info) -> api_error override; + [[nodiscard]] auto utimens_impl(std::string api_path, + const struct timespec tv[2], + struct fuse_file_info *f_info) + -> api_error override; #else - [[nodiscard]] auto - utimens_impl(std::string api_path, - const struct timespec tv[2]) -> api_error override; + [[nodiscard]] auto utimens_impl(std::string api_path, + const struct timespec tv[2]) + -> api_error override; #endif - [[nodiscard]] auto - write_impl(std::string api_path, const char *buffer, size_t write_size, - off_t write_offset, struct fuse_file_info *f_info, - std::size_t &bytes_written) -> api_error override; + [[nodiscard]] auto write_impl(std::string api_path, const char *buffer, + size_t write_size, off_t write_offset, + struct fuse_file_info *f_info, + std::size_t &bytes_written) + -> api_error override; }; } // namespace remote_fuse } // namespace repertory diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp index e7b0e675..5ccb1c63 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp @@ -34,78 +34,75 @@ namespace remote_fuse { class remote_server final : public virtual remote_server_base { public: remote_server(app_config &config, i_fuse_drive &drive, - const std::string &mount_location); + std::string_view mount_location); private: directory_cache directory_cache_; std::atomic next_handle_{0U}; private: - [[nodiscard]] auto construct_path(std::string path) -> std::string; + [[nodiscard]] auto construct_path(std::string_view path) -> std::string; - [[nodiscard]] auto construct_path(const std::wstring &path) -> std::string; + [[nodiscard]] auto construct_path(std::wstring_view path) -> std::string; [[nodiscard]] static auto empty_as_zero(const json &data) -> std::string; [[nodiscard]] auto get_next_handle() -> std::uint64_t; - [[nodiscard]] auto populate_file_info(const std::string &api_path, - remote::file_info &file_info) + [[nodiscard]] auto populate_file_info(std::string_view api_path, + remote::file_info &r_info) -> packet::error_type; - void populate_file_info(const std::string &api_path, const UINT64 &file_size, - const UINT32 &attributes, - remote::file_info &file_info); + void populate_file_info(std::string_view api_path, UINT64 file_size, + UINT32 attributes, remote::file_info &r_info); - static void populate_stat(const struct stat64 &unix_st, remote::stat &r_stat); + static void populate_stat(const struct stat64 &u_stat, remote::stat &r_stat); - [[nodiscard]] auto update_to_windows_format(const std::string &root_api_path, + [[nodiscard]] auto update_to_windows_format(std::string_view root_api_path, json &item) -> json &; public: // FUSE Layer - [[nodiscard]] auto fuse_access(const char *path, const std::int32_t &mask) + [[nodiscard]] auto fuse_access(const char *path, std::int32_t mask) -> packet::error_type override; [[nodiscard]] auto fuse_chflags(const char *path, std::uint32_t flags) -> packet::error_type override; - [[nodiscard]] auto fuse_chmod(const char *path, const remote::file_mode &mode) + [[nodiscard]] auto fuse_chmod(const char *path, remote::file_mode mode) -> packet::error_type override; - [[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid, - const remote::group_id &gid) + [[nodiscard]] auto fuse_chown(const char *path, remote::user_id uid, + remote::group_id gid) -> packet::error_type override; - [[nodiscard]] auto - fuse_create(const char *path, const remote::file_mode &mode, - const remote::open_flags &flags, remote::file_handle &handle) + [[nodiscard]] auto fuse_create(const char *path, remote::file_mode mode, + const remote::open_flags &flags, + remote::file_handle &handle) -> packet::error_type override; [[nodiscard]] auto fuse_destroy() -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_fallocate(const char *path, const - std::int32_t &mode, const remote::file_offset &offset, const - remote::file_offset &length, const remote::file_handle &handle) override + std::int32_t &mode, remote::file_offset offset, const + remote::file_offset length, remote::file_handle handle) override ;*/ [[nodiscard]] auto fuse_fgetattr(const char *path, remote::stat &r_stat, - bool &directory, - const remote::file_handle &handle) + bool &directory, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_fsetattr_x(const char *path, const remote::setattr_x &attr, - const remote::file_handle &handle) + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto fuse_fsync(const char *path, const std::int32_t &datasync, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_fsync(const char *path, std::int32_t datasync, + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto fuse_ftruncate(const char *path, - const remote::file_offset &size, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_ftruncate(const char *path, remote::file_offset size, + remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &r_stat, @@ -113,10 +110,10 @@ public: -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_getxattr(const char *path, const char - *name, char *value, const remote::file_size &size) override ; + *name, char *value, remote::file_size size) override ; [[nodiscard]] packet::error_type fuse_getxattrOSX(const char *path, const char - *name, char *value, const remote::file_size &size, std::uint32_t position) + *name, char *value, remote::file_size size, std::uint32_t position) override ;*/ [[nodiscard]] auto fuse_getxtimes(const char *path, @@ -127,10 +124,10 @@ public: [[nodiscard]] auto fuse_init() -> packet::error_type override; [[nodiscard]] /*packet::error_type fuse_listxattr(const char *path, char - *buffer, const remote::file_size &size) override ;*/ + *buffer, remote::file_size size) override ;*/ [[nodiscard]] auto - fuse_mkdir(const char *path, const remote::file_mode &mode) + fuse_mkdir(const char *path, remote::file_mode mode) -> packet::error_type override; [[nodiscard]] auto fuse_open(const char *path, @@ -141,26 +138,24 @@ public: [[nodiscard]] auto fuse_opendir(const char *path, remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_read(const char *path, char *buffer, - const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) + [[nodiscard]] auto + fuse_read(const char *path, char *buffer, remote::file_size read_size, + remote::file_offset read_offset, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_rename(const char *from, const char *to) -> packet::error_type override; - [[nodiscard]] auto - fuse_readdir(const char *path, const remote::file_offset &offset, - const remote::file_handle &handle, std::string &item_path) + [[nodiscard]] auto fuse_readdir(const char *path, remote::file_offset offset, + remote::file_handle handle, + std::string &item_path) -> packet::error_type override; - [[nodiscard]] auto fuse_release(const char *path, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_release(const char *path, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_releasedir(const char *path, - const remote::file_handle &handle) + remote::file_handle handle) -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_removexattr(const char *path, const @@ -174,26 +169,25 @@ public: -> packet::error_type override; [[nodiscard]] auto fuse_setbkuptime(const char *path, - const remote::file_time &bkuptime) + remote::file_time bkuptime) -> packet::error_type override; [[nodiscard]] auto fuse_setchgtime(const char *path, - const remote::file_time &chgtime) + remote::file_time chgtime) -> packet::error_type override; - [[nodiscard]] auto fuse_setcrtime(const char *path, - const remote::file_time &crtime) + [[nodiscard]] auto fuse_setcrtime(const char *path, remote::file_time crtime) -> packet::error_type override; [[nodiscard]] auto fuse_setvolname(const char *volname) -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_setxattr(const char *path, const char - *name, const char *value, const remote::file_size &size, const std::int32_t + *name, const char *value, remote::file_size size, const std::int32_t &flags) override ; [[nodiscard]] packet::error_type fuse_setxattr_osx(const char *path, const - char *name, const char *value, const remote::file_size &size, const + char *name, const char *value, remote::file_size size, const std::int32_t &flags, std::uint32_t position) override ;*/ [[nodiscard]] auto fuse_statfs(const char *path, std::uint64_t frsize, @@ -204,8 +198,7 @@ public: remote::statfs_x &r_stat) -> packet::error_type override; - [[nodiscard]] auto fuse_truncate(const char *path, - const remote::file_offset &size) + [[nodiscard]] auto fuse_truncate(const char *path, remote::file_offset size) -> packet::error_type override; [[nodiscard]] auto fuse_unlink(const char *path) @@ -215,20 +208,18 @@ public: std::uint64_t op0, std::uint64_t op1) -> packet::error_type override; - [[nodiscard]] auto fuse_write(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) + [[nodiscard]] auto + fuse_write(const char *path, const char *buffer, remote::file_size write_size, + remote::file_offset write_offset, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) + remote::file_size write_size, + remote::file_offset write_offset, + remote::file_handle handle) -> packet::error_type override; - void set_fuse_uid_gid(const remote::user_id &, - const remote::group_id &) override {} + void set_fuse_uid_gid(remote::user_id, remote::group_id) override {} // JSON Layer [[nodiscard]] auto winfsp_get_dir_buffer(PVOID /*file_desc*/, @@ -237,17 +228,18 @@ public: return static_cast(STATUS_INVALID_HANDLE); } - [[nodiscard]] auto json_create_directory_snapshot(const std::string &path, + [[nodiscard]] auto json_create_directory_snapshot(std::string_view path, json &json_data) -> packet::error_type override; - [[nodiscard]] auto json_read_directory_snapshot( - const std::string &path, const remote::file_handle &handle, - std::uint32_t page, json &json_data) -> packet::error_type override; + [[nodiscard]] auto json_read_directory_snapshot(std::string_view path, + remote::file_handle handle, + std::uint32_t page, + json &json_data) + -> packet::error_type override; - [[nodiscard]] auto - json_release_directory_snapshot(const std::string &path, - const remote::file_handle &handle) + [[nodiscard]] auto json_release_directory_snapshot(std::string_view path, + remote::file_handle handle) -> packet::error_type override; // WinFSP Layer @@ -264,14 +256,14 @@ public: [[nodiscard]] auto winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, UINT32 attributes, UINT64 /*allocation_size*/, PVOID *file_desc, - remote::file_info *file_info, std::string &normalized_name, + remote::file_info *r_info, std::string &normalized_name, BOOLEAN &exists) -> packet::error_type override; - [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto @@ -285,19 +277,19 @@ public: std::string &volume_label) -> packet::error_type override; - [[nodiscard]] auto winfsp_mounted(const std::wstring &location) + [[nodiscard]] auto winfsp_mounted(std::wstring_view location) -> packet::error_type override; [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, + remote::file_info *r_info, std::string &normalized_name) -> packet::error_type override; [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, UINT64 /*allocation_size*/, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, @@ -316,20 +308,20 @@ public: [[nodiscard]] auto winfsp_set_basic_info( PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, - remote::file_info *file_info) -> packet::error_type override; + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; - [[nodiscard]] auto winfsp_unmounted(const std::wstring &location) + [[nodiscard]] auto winfsp_unmounted(std::wstring_view location) -> packet::error_type override; [[nodiscard]] auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PUINT32 bytes_transferred, remote::file_info *file_info) + PUINT32 bytes_transferred, remote::file_info *r_info) -> packet::error_type override; }; } // namespace remote_fuse diff --git a/repertory/librepertory/include/drives/remote/i_remote_json.hpp b/repertory/librepertory/include/drives/remote/i_remote_json.hpp index 74067975..571e1b46 100644 --- a/repertory/librepertory/include/drives/remote/i_remote_json.hpp +++ b/repertory/librepertory/include/drives/remote/i_remote_json.hpp @@ -30,16 +30,18 @@ class i_remote_json { public: [[nodiscard]] virtual auto - json_create_directory_snapshot(const std::string &path, - json &json_data) -> packet::error_type = 0; + json_create_directory_snapshot(std::string_view path, json &json_data) + -> packet::error_type = 0; - [[nodiscard]] virtual auto json_read_directory_snapshot( - const std::string &path, const remote::file_handle &handle, - std::uint32_t page, json &json_data) -> packet::error_type = 0; + [[nodiscard]] virtual auto + json_read_directory_snapshot(std::string_view path, + remote::file_handle handle, std::uint32_t page, + json &json_data) -> packet::error_type = 0; - [[nodiscard]] virtual auto json_release_directory_snapshot( - const std::string &path, - const remote::file_handle &handle) -> packet::error_type = 0; + [[nodiscard]] virtual auto + json_release_directory_snapshot(std::string_view path, + remote::file_handle handle) + -> packet::error_type = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp b/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp index f21bf480..0c37b17e 100644 --- a/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp +++ b/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp @@ -62,9 +62,9 @@ private: mutable std::recursive_mutex file_mutex_; protected: - void add_directory(const std::string &client_id, std::uint64_t handle); + void add_directory(std::string_view client_id, std::uint64_t handle); - void close_all(const std::string &client_id); + void close_all(std::string_view client_id); #if defined(_WIN32) [[nodiscard]] auto get_directory_buffer(const native_handle &handle, @@ -77,10 +77,10 @@ protected: [[nodiscard]] auto get_open_info(const native_handle &handle, open_info &oi) -> bool; - [[nodiscard]] auto has_open_directory(const std::string &client_id, + [[nodiscard]] auto has_open_directory(std::string_view client_id, std::uint64_t handle) -> bool; - [[nodiscard]] auto has_compat_open_info(const remote::file_handle &handle, + [[nodiscard]] auto has_compat_open_info(remote::file_handle handle, int error_return) -> int; template @@ -91,29 +91,29 @@ protected: return handle_lookup_.contains(handle) ? 0 : error_return; } - void remove_all(const std::string &file_path); + void remove_all(std::string_view file_path); void remove_and_close_all(const native_handle &handle); - void remove_compat_open_info(const remote::file_handle &handle); + void remove_compat_open_info(remote::file_handle handle); - auto remove_directory(const std::string &client_id, std::uint64_t handle) + auto remove_directory(std::string_view client_id, std::uint64_t handle) -> bool; void remove_open_info(const native_handle &handle); - void set_client_id(const native_handle &handle, const std::string &client_id); + void set_client_id(const native_handle &handle, std::string_view client_id); - void set_compat_client_id(const remote::file_handle &handle, - const std::string &client_id); + void set_compat_client_id(remote::file_handle handle, + std::string_view client_id); - void set_compat_open_info(const remote::file_handle &handle, - const std::string &file_path); + void set_compat_open_info(remote::file_handle handle, + std::string_view file_path); void set_open_info(const native_handle &handle, open_info op_info); public: - [[nodiscard]] auto get_open_file_count(const std::string &file_path) const + [[nodiscard]] auto get_open_file_count(std::string_view file_path) const -> std::size_t; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/remote/remote_server_base.hpp b/repertory/librepertory/include/drives/remote/remote_server_base.hpp index 4263ba4a..804b3ec5 100644 --- a/repertory/librepertory/include/drives/remote/remote_server_base.hpp +++ b/repertory/librepertory/include/drives/remote/remote_server_base.hpp @@ -38,6 +38,7 @@ #include "types/repertory.hpp" #include "utils/base64.hpp" #include "utils/path.hpp" +#include "utils/polling.hpp" namespace repertory { template @@ -46,8 +47,8 @@ class remote_server_base : public remote_open_file_table, public virtual remote_fuse::i_remote_instance { public: using handler_callback = std::function; + std::uint32_t, std::string, std::uint64_t, std::string, packet *, + packet &)>; public: remote_server_base(const remote_server_base &) = delete; @@ -56,11 +57,11 @@ public: auto operator=(remote_server_base &&) -> remote_server_base & = delete; public: - remote_server_base(app_config &config, drive &drv, std::string mount_location) + remote_server_base(app_config &config, drive &drv, + std::string_view mount_location) : config_(config), drive_(drv), - mount_location_(std::move(mount_location)), - client_pool_(config.get_remote_mount().client_pool_size) { + mount_location_(std::string(mount_location)) { REPERTORY_USES_FUNCTION_NAME(); event_system::instance().raise(function_name, @@ -77,6 +78,13 @@ public: method, request, response, message_complete); }); + + polling::instance().set_callback({ + "remote_server_expired", + polling::frequency::high, + [this](auto && /* stop */) { client_pool_.remove_expired(); }, + }); + event_system::instance().raise(function_name, "remote_server_base"); } @@ -86,7 +94,10 @@ public: event_system::instance().raise(function_name, "remote_server_base"); + polling::instance().remove_callback("remote_server_expired"); + client_pool_.shutdown(); + packet_server_.reset(); event_system::instance().raise(function_name, "remote_server_base"); @@ -556,7 +567,7 @@ private: }; private: - void closed_handler(const std::string &client_id) { + void closed_handler(std::string client_id) { client_pool_.remove_client(client_id); close_all(client_id); } @@ -613,7 +624,7 @@ private: return this->fuse_chown(path.c_str(), uid, gid); } - [[nodiscard]] auto handle_fuse_create(const std::string &client_id, + [[nodiscard]] auto handle_fuse_create(std::string_view client_id, packet *request, packet &response) -> packet::error_type { auto ret{0}; @@ -660,13 +671,13 @@ private: remote::group_id gid{}; DECODE_OR_RETURN(request, gid); - remote::stat st{}; + remote::stat r_stat{}; bool directory = false; - ret = this->fuse_fgetattr(path.data(), st, directory, handle); + ret = this->fuse_fgetattr(path.data(), r_stat, directory, handle); if (ret == 0) { - st.st_uid = uid; - st.st_gid = gid; - response.encode(st); + r_stat.st_uid = uid; + r_stat.st_gid = gid; + response.encode(r_stat); response.encode(static_cast(directory)); } @@ -733,13 +744,13 @@ private: remote::group_id gid; DECODE_OR_RETURN(request, gid); - remote::stat st{}; + remote::stat r_stat{}; bool directory = false; - ret = this->fuse_getattr(path.c_str(), st, directory); + ret = this->fuse_getattr(path.c_str(), r_stat, directory); if (ret == 0) { - st.st_uid = uid; - st.st_gid = gid; - response.encode(st); + r_stat.st_uid = uid; + r_stat.st_gid = gid; + response.encode(r_stat); response.encode(static_cast(directory)); } return ret; @@ -779,7 +790,7 @@ private: return this->fuse_mkdir(path.c_str(), mode); } - [[nodiscard]] auto handle_fuse_open(const std::string &client_id, + [[nodiscard]] auto handle_fuse_open(std::string_view client_id, packet *request, packet &response) -> packet::error_type { auto ret{0}; @@ -803,7 +814,7 @@ private: return ret; } - [[nodiscard]] auto handle_fuse_opendir(const std::string &client_id, + [[nodiscard]] auto handle_fuse_opendir(std::string_view client_id, packet *request, packet &response) -> packet::error_type { auto ret{0}; @@ -846,7 +857,7 @@ private: return ret; } - [[nodiscard]] auto handle_fuse_readdir(const std::string &client_id, + [[nodiscard]] auto handle_fuse_readdir(std::string_view client_id, packet *request, packet &response) -> packet::error_type { auto ret{0}; @@ -886,7 +897,7 @@ private: return this->fuse_release(path.c_str(), handle); } - [[nodiscard]] auto handle_fuse_releasedir(const std::string &client_id, + [[nodiscard]] auto handle_fuse_releasedir(std::string_view client_id, packet *request) -> packet::error_type { auto ret{0}; @@ -997,10 +1008,10 @@ private: std::uint64_t frsize{}; DECODE_OR_RETURN(request, frsize); - remote::statfs st{}; - ret = this->fuse_statfs(path.data(), frsize, st); + remote::statfs r_stat{}; + ret = this->fuse_statfs(path.data(), frsize, r_stat); if (ret == 0) { - response.encode(st); + response.encode(r_stat); } return ret; @@ -1016,10 +1027,10 @@ private: std::uint64_t bsize{}; DECODE_OR_RETURN(request, bsize); - remote::statfs_x st{}; - ret = this->fuse_statfs_x(path.data(), bsize, st); + remote::statfs_x r_stat{}; + ret = this->fuse_statfs_x(path.data(), bsize, r_stat); if (ret == 0) { - response.encode(st); + response.encode(r_stat); } return ret; } @@ -1131,7 +1142,7 @@ private: } [[nodiscard]] auto - handle_json_create_directory_snapshot(const std::string &client_id, + handle_json_create_directory_snapshot(std::string_view client_id, packet *request, packet &response) -> packet::error_type { std::int32_t ret{}; @@ -1152,7 +1163,7 @@ private: } [[nodiscard]] auto - handle_json_read_directory_snapshot(const std::string &client_id, + handle_json_read_directory_snapshot(std::string_view client_id, packet *request, packet &response) -> packet::error_type { std::int32_t ret{0}; @@ -1181,7 +1192,7 @@ private: } [[nodiscard]] auto handle_json_release_directory_snapshot( - const std::string &client_id, packet *request) -> packet::error_type { + std::string_view client_id, packet *request) -> packet::error_type { std::int32_t ret{0}; std::string path; @@ -1240,7 +1251,7 @@ private: return this->winfsp_close(file_desc); } - [[nodiscard]] auto handle_winfsp_create(const std::string &client_id, + [[nodiscard]] auto handle_winfsp_create(std::string_view client_id, packet *request, packet &response) -> packet::error_type { auto ret = static_cast(STATUS_SUCCESS); @@ -1261,12 +1272,12 @@ private: DECODE_OR_RETURN(request, allocation_size); BOOLEAN exists{0}; - remote::file_info file_info{}; + remote::file_info r_info{}; std::string normalized_name; PVOID file_desc{}; ret = this->winfsp_create(file_name.data(), create_options, granted_access, - attributes, allocation_size, &file_desc, - &file_info, normalized_name, exists); + attributes, allocation_size, &file_desc, &r_info, + normalized_name, exists); if (ret == STATUS_SUCCESS) { if (exists == 0U) { #if defined(_WIN32) @@ -1279,7 +1290,7 @@ private: } response.encode(file_desc); - response.encode(file_info); + response.encode(r_info); response.encode(normalized_name); response.encode(exists); } @@ -1294,10 +1305,10 @@ private: HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); - remote::file_info file_info{}; - ret = this->winfsp_flush(file_desc, &file_info); + remote::file_info r_info{}; + ret = this->winfsp_flush(file_desc, &r_info); if (ret == STATUS_SUCCESS) { - response.encode(file_info); + response.encode(r_info); } return ret; @@ -1311,10 +1322,10 @@ private: HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); - remote::file_info file_info{}; - ret = this->winfsp_get_file_info(file_desc, &file_info); + remote::file_info r_info{}; + ret = this->winfsp_get_file_info(file_desc, &r_info); if (ret == STATUS_SUCCESS) { - response.encode(file_info); + response.encode(r_info); } return ret; } @@ -1380,7 +1391,7 @@ private: return ret; } - [[nodiscard]] auto handle_winfsp_open(const std::string &client_id, + [[nodiscard]] auto handle_winfsp_open(std::string_view client_id, packet *request, packet &response) -> packet::error_type { auto ret = static_cast(STATUS_SUCCESS); @@ -1394,11 +1405,11 @@ private: UINT32 granted_access{}; DECODE_OR_RETURN(request, granted_access); - remote::file_info file_info{}; + remote::file_info r_info{}; std::string normalized_name; PVOID file_desc{}; ret = this->winfsp_open(file_name.data(), create_options, granted_access, - &file_desc, &file_info, normalized_name); + &file_desc, &r_info, normalized_name); if (ret == STATUS_SUCCESS) { #if defined(_WIN32) this->set_client_id(file_desc, client_id); @@ -1408,7 +1419,7 @@ private: client_id); #endif // defined(_WIN32) response.encode(file_desc); - response.encode(file_info); + response.encode(r_info); response.encode(normalized_name); } @@ -1431,11 +1442,11 @@ private: UINT64 allocation_size{}; DECODE_OR_RETURN(request, allocation_size); - remote::file_info file_info{}; + remote::file_info r_info{}; ret = this->winfsp_overwrite(file_desc, attributes, replace_attributes, - allocation_size, &file_info); + allocation_size, &r_info); if (ret == STATUS_SUCCESS) { - response.encode(file_info); + response.encode(r_info); } return ret; } @@ -1536,12 +1547,12 @@ private: UINT64 change_time{}; DECODE_OR_RETURN(request, change_time); - remote::file_info file_info{}; + remote::file_info r_info{}; ret = this->winfsp_set_basic_info(file_desc, attributes, creation_time, last_access_time, last_write_time, - change_time, &file_info); + change_time, &r_info); if (ret == STATUS_SUCCESS) { - response.encode(file_info); + response.encode(r_info); } return ret; } @@ -1560,11 +1571,11 @@ private: BOOLEAN set_allocation_size{}; DECODE_OR_RETURN(request, set_allocation_size); - remote::file_info file_info{}; + remote::file_info r_info{}; ret = this->winfsp_set_file_size(file_desc, new_size, set_allocation_size, - &file_info); + &r_info); if (ret == STATUS_SUCCESS) { - response.encode(file_info); + response.encode(r_info); } return ret; } @@ -1601,20 +1612,20 @@ private: auto *buffer = request->current_pointer(); UINT32 bytes_transferred{0U}; - remote::file_info file_info{}; + remote::file_info r_info{}; ret = this->winfsp_write(file_desc, buffer, offset, length, write_to_end, - constrained_io, &bytes_transferred, &file_info); + constrained_io, &bytes_transferred, &r_info); if (ret == STATUS_SUCCESS) { response.encode(bytes_transferred); - response.encode(file_info); + response.encode(r_info); } return ret; } void - message_handler(std::uint32_t service_flags, const std::string &client_id, - std::uint64_t thread_id, const std::string &method, - packet *request, packet &response, + message_handler(std::uint32_t service_flags, std::string client_id, + std::uint64_t thread_id, std::string method, packet *request, + packet &response, packet_server::message_complete_callback message_complete) { auto idx{method.find_last_of("::")}; auto lookup_method_name{ @@ -1632,7 +1643,7 @@ private: return this->handler_lookup_.at(lookup_method_name)( service_flags, client_id, thread_id, method, request, response); }, - message_complete); + std::move(message_complete)); } protected: diff --git a/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp index e33e2e78..54e81a39 100644 --- a/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp @@ -32,22 +32,22 @@ class i_winfsp_drive { public: [[nodiscard]] virtual auto - get_directory_item_count(const std::string &api_path) const + get_directory_item_count(std::string_view api_path) const -> std::uint64_t = 0; [[nodiscard]] virtual auto - get_directory_items(const std::string &api_path) const + get_directory_items(std::string_view api_path) const -> directory_item_list = 0; - [[nodiscard]] virtual auto get_file_size(const std::string &api_path) const + [[nodiscard]] virtual auto get_file_size(std::string_view api_path) const -> std::uint64_t = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, - const std::string &name, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, + std::string_view name, std::string &value) const -> api_error = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error = 0; @@ -65,8 +65,8 @@ public: virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size, std::string &volume_label) const = 0; - [[nodiscard]] virtual auto populate_file_info(const std::string &api_path, - remote::file_info &fi) const + [[nodiscard]] virtual auto populate_file_info(std::string_view api_path, + remote::file_info &r_info) const -> api_error = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp index 819e0098..05c90d98 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp @@ -42,19 +42,19 @@ public: [[nodiscard]] virtual auto winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, UINT32 file_attributes, UINT64 allocation_size, - PVOID *file_desc, remote::file_info *file_info, + PVOID *file_desc, remote::file_info *r_info, std::string &normalized_name, BOOLEAN &exists) -> packet::error_type = 0; [[nodiscard]] virtual auto winfsp_flush(PVOID file_desc, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type = 0; [[nodiscard]] virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) -> packet::error_type = 0; [[nodiscard]] virtual auto winfsp_get_file_info(PVOID file_desc, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type = 0; [[nodiscard]] virtual auto @@ -68,18 +68,18 @@ public: std::string &volume_label) -> packet::error_type = 0; - [[nodiscard]] virtual auto winfsp_mounted(const std::wstring &location) + [[nodiscard]] virtual auto winfsp_mounted(std::wstring_view location) -> packet::error_type = 0; [[nodiscard]] virtual auto winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, - PVOID *file_desc, remote::file_info *file_info, + PVOID *file_desc, remote::file_info *r_info, std::string &normalized_name) -> packet::error_type = 0; [[nodiscard]] virtual auto winfsp_overwrite(PVOID file_desc, UINT32 file_attributes, BOOLEAN replace_file_attributes, UINT64 allocation_size, - remote::file_info *file_info) -> packet::error_type = 0; + remote::file_info *r_info) -> packet::error_type = 0; [[nodiscard]] virtual auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, @@ -100,21 +100,20 @@ public: winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, - remote::file_info *file_info) -> packet::error_type = 0; + remote::file_info *r_info) -> packet::error_type = 0; - [[nodiscard]] virtual auto winfsp_set_file_size(PVOID file_desc, - UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) + [[nodiscard]] virtual auto + winfsp_set_file_size(PVOID file_desc, UINT64 new_size, + BOOLEAN set_allocation_size, remote::file_info *r_info) -> packet::error_type = 0; - [[nodiscard]] virtual auto winfsp_unmounted(const std::wstring &location) + [[nodiscard]] virtual auto winfsp_unmounted(std::wstring_view location) -> packet::error_type = 0; [[nodiscard]] virtual auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PUINT32 bytes_transferred, remote::file_info *file_info) + PUINT32 bytes_transferred, remote::file_info *r_info) -> packet::error_type = 0; }; diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp index 15c858ae..3087a9a0 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp @@ -50,17 +50,18 @@ private: public: [[nodiscard]] auto check() -> packet::error_type; - [[nodiscard]] auto json_create_directory_snapshot(const std::string &path, + [[nodiscard]] auto json_create_directory_snapshot(std::string_view path, json &json_data) -> packet::error_type override; - [[nodiscard]] auto json_read_directory_snapshot( - const std::string &path, const remote::file_handle &handle, - std::uint32_t page, json &json_data) -> packet::error_type override; + [[nodiscard]] auto json_read_directory_snapshot(std::string_view path, + remote::file_handle handle, + std::uint32_t page, + json &json_data) + -> packet::error_type override; - [[nodiscard]] auto - json_release_directory_snapshot(const std::string &path, - const remote::file_handle &handle) + [[nodiscard]] auto json_release_directory_snapshot(std::string_view path, + remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) @@ -76,17 +77,17 @@ public: [[nodiscard]] auto winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, UINT32 attributes, UINT64 allocation_size, PVOID *file_desc, - remote::file_info *file_info, std::string &normalized_name, + remote::file_info *r_info, std::string &normalized_name, BOOLEAN &exists) -> packet::error_type override; - [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) -> packet::error_type override; [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_get_security_by_name( @@ -98,19 +99,19 @@ public: std::string &volume_label) -> packet::error_type override; - [[nodiscard]] auto winfsp_mounted(const std::wstring &location) + [[nodiscard]] auto winfsp_mounted(std::wstring_view location) -> packet::error_type override; [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, + remote::file_info *r_info, std::string &normalized_name) -> packet::error_type override; [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, UINT64 allocation_size, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, @@ -129,20 +130,20 @@ public: [[nodiscard]] auto winfsp_set_basic_info( PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, - remote::file_info *file_info) -> packet::error_type override; + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; - [[nodiscard]] auto winfsp_unmounted(const std::wstring &location) + [[nodiscard]] auto winfsp_unmounted(std::wstring_view location) -> packet::error_type override; [[nodiscard]] auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PUINT32 bytes_transferred, remote::file_info *file_info) + PUINT32 bytes_transferred, remote::file_info *r_info) -> packet::error_type override; }; } // namespace remote_winfsp diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp index 7ff71b42..7a4b4193 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp @@ -36,64 +36,63 @@ namespace remote_winfsp { class remote_server final : public virtual remote_server_base { public: remote_server(app_config &config, i_winfsp_drive &drive, - const std::string &mount_location) - : remote_server_base(config, drive, - utils::string::to_lower(mount_location)) {} + std::string_view mount_location) + : remote_server_base( + config, drive, + utils::string::to_lower(std::string{mount_location})) {} private: directory_cache directory_cache_; std::atomic next_handle_{0U}; private: - [[nodiscard]] auto construct_path(std::string path) -> std::string; + [[nodiscard]] auto construct_path(std::string_view path) -> std::string; [[nodiscard]] auto get_next_handle() -> std::uint64_t; - [[nodiscard]] auto populate_file_info(const std::string &api_path, - remote::file_info &file_info) + [[nodiscard]] auto populate_file_info(std::string_view api_path, + remote::file_info &r_info) -> packet::error_type; void populate_stat(const char *path, bool directory, remote::stat &r_stat, - const struct _stat64 &unix_st); + const struct _stat64 &u_stat); public: // FUSE Layer - [[nodiscard]] auto fuse_access(const char *path, const std::int32_t &mask) + [[nodiscard]] auto fuse_access(const char *path, std::int32_t mask) -> packet::error_type override; [[nodiscard]] auto fuse_chflags(const char *path, std::uint32_t flags) -> packet::error_type override; - [[nodiscard]] auto fuse_chmod(const char *path, const remote::file_mode &mode) + [[nodiscard]] auto fuse_chmod(const char *path, remote::file_mode mode) -> packet::error_type override; - [[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid, - const remote::group_id &gid) + [[nodiscard]] auto fuse_chown(const char *path, remote::user_id uid, + remote::group_id gid) -> packet::error_type override; [[nodiscard]] auto fuse_destroy() -> packet::error_type override; /*packet::error_type fuse_fallocate(const char *path, const std::int32_t - &mode, const remote::file_offset &offset, const remote::file_offset - &length, const remote::file_handle &handle) override ;*/ + &mode, remote::file_offset offset, const remote::file_offset + &length, remote::file_handle handle) override ;*/ [[nodiscard]] auto fuse_fgetattr(const char *path, remote::stat &r_stat, - bool &directory, - const remote::file_handle &handle) + bool &directory, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_fsetattr_x(const char *path, const remote::setattr_x &attr, - const remote::file_handle &handle) + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto fuse_fsync(const char *path, const std::int32_t &datasync, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_fsync(const char *path, std::int32_t datasync, + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto fuse_ftruncate(const char *path, - const remote::file_offset &size, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_ftruncate(const char *path, remote::file_offset size, + remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &r_stat, @@ -101,10 +100,10 @@ public: -> packet::error_type override; /*packet::error_type fuse_getxattr(const char *path, const char *name, char - *value, const remote::file_size &size) override ; + *value, remote::file_size size) override ; packet::error_type fuse_getxattrOSX(const char *path, const char *name, char - *value, const remote::file_size &size, std::uint32_t position) override ;*/ + *value, remote::file_size size, std::uint32_t position) override ;*/ [[nodiscard]] auto fuse_getxtimes(const char *path, remote::file_time &bkuptime, @@ -114,18 +113,18 @@ public: [[nodiscard]] auto fuse_init() -> packet::error_type override; /*packet::error_type fuse_listxattr(const char *path, char *buffer, - const remote::file_size &size) override + remote::file_size size) override ;*/ - [[nodiscard]] auto fuse_mkdir(const char *path, const remote::file_mode &mode) + [[nodiscard]] auto fuse_mkdir(const char *path, remote::file_mode mode) -> packet::error_type override; [[nodiscard]] auto fuse_opendir(const char *path, remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto - fuse_create(const char *path, const remote::file_mode &mode, - const remote::open_flags &flags, remote::file_handle &handle) + [[nodiscard]] auto fuse_create(const char *path, remote::file_mode mode, + const remote::open_flags &flags, + remote::file_handle &handle) -> packet::error_type override; [[nodiscard]] auto fuse_open(const char *path, @@ -133,38 +132,35 @@ public: remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_read(const char *path, char *buffer, - const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) + [[nodiscard]] auto + fuse_read(const char *path, char *buffer, remote::file_size read_size, + remote::file_offset read_offset, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_rename(const char *from, const char *to) -> packet::error_type override; - [[nodiscard]] auto fuse_write(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) + [[nodiscard]] auto + fuse_write(const char *path, const char *buffer, remote::file_size write_size, + remote::file_offset write_offset, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) + remote::file_size write_size, + remote::file_offset write_offset, + remote::file_handle handle) -> packet::error_type override; - [[nodiscard]] auto - fuse_readdir(const char *path, const remote::file_offset &offset, - const remote::file_handle &handle, std::string &item_path) + [[nodiscard]] auto fuse_readdir(const char *path, remote::file_offset offset, + remote::file_handle handle, + std::string &item_path) -> packet::error_type override; - [[nodiscard]] auto fuse_release(const char *path, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_release(const char *path, remote::file_handle handle) -> packet::error_type override; [[nodiscard]] auto fuse_releasedir(const char *path, - const remote::file_handle &handle) + remote::file_handle handle) -> packet::error_type override; /*packet::error_type fuse_removexattr(const char *path, const char *name) @@ -177,26 +173,25 @@ public: -> packet::error_type override; [[nodiscard]] auto fuse_setbkuptime(const char *path, - const remote::file_time &bkuptime) + remote::file_time bkuptime) -> packet::error_type override; [[nodiscard]] auto fuse_setchgtime(const char *path, - const remote::file_time &chgtime) + remote::file_time chgtime) -> packet::error_type override; - [[nodiscard]] auto fuse_setcrtime(const char *path, - const remote::file_time &crtime) + [[nodiscard]] auto fuse_setcrtime(const char *path, remote::file_time crtime) -> packet::error_type override; [[nodiscard]] auto fuse_setvolname(const char *volname) -> packet::error_type override; /*packet::error_type fuse_setxattr(const char *path, const char *name, const - char *value, const remote::file_size &size, const std::int32_t &flags) + char *value, remote::file_size size, std::int32_t flags) override ; packet::error_type fuse_setxattr_osx(const char *path, const char *name, const - char *value, const remote::file_size &size, const std::int32_t &flags, + char *value, remote::file_size size, std::int32_t flags, std::uint32_t position) override ;*/ [[nodiscard]] auto fuse_statfs(const char *path, std::uint64_t frsize, @@ -207,8 +202,7 @@ public: remote::statfs_x &r_stat) -> packet::error_type override; - [[nodiscard]] auto fuse_truncate(const char *path, - const remote::file_offset &size) + [[nodiscard]] auto fuse_truncate(const char *path, remote::file_offset size) -> packet::error_type override; [[nodiscard]] auto fuse_unlink(const char *path) @@ -218,21 +212,22 @@ public: std::uint64_t op0, std::uint64_t op1) -> packet::error_type override; - void set_fuse_uid_gid(const remote::user_id & /* uid */, - const remote::group_id & /* gid */) override {} + void set_fuse_uid_gid(remote::user_id /* uid */, + remote::group_id /* gid */) override {} // JSON Layer - [[nodiscard]] auto json_create_directory_snapshot(const std::string &path, + [[nodiscard]] auto json_create_directory_snapshot(std::string_view path, json &json_data) -> packet::error_type override; - [[nodiscard]] auto json_read_directory_snapshot( - const std::string &path, const remote::file_handle &handle, - std::uint32_t page, json &json_data) -> packet::error_type override; + [[nodiscard]] auto json_read_directory_snapshot(std::string_view path, + remote::file_handle handle, + std::uint32_t page, + json &json_data) + -> packet::error_type override; - [[nodiscard]] auto - json_release_directory_snapshot(const std::string &path, - const remote::file_handle &handle) + [[nodiscard]] auto json_release_directory_snapshot(std::string_view path, + remote::file_handle handle) -> packet::error_type override; // WinFSP Layer @@ -249,17 +244,17 @@ public: [[nodiscard]] auto winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, UINT32 attributes, UINT64 allocation_size, PVOID *file_desc, - remote::file_info *file_info, std::string &normalized_name, + remote::file_info *r_info, std::string &normalized_name, BOOLEAN &exists) -> packet::error_type override; - [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) -> packet::error_type override; [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_get_security_by_name( @@ -271,19 +266,19 @@ public: std::string &volume_label) -> packet::error_type override; - [[nodiscard]] auto winfsp_mounted(const std::wstring &location) + [[nodiscard]] auto winfsp_mounted(std::wstring_view location) -> packet::error_type override; [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, + remote::file_info *r_info, std::string &normalized_name) -> packet::error_type override; [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, UINT64 allocation_size, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, @@ -302,20 +297,20 @@ public: [[nodiscard]] auto winfsp_set_basic_info( PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, - remote::file_info *file_info) -> packet::error_type override; + remote::file_info *r_info) -> packet::error_type override; [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, - remote::file_info *file_info) + remote::file_info *r_info) -> packet::error_type override; - [[nodiscard]] auto winfsp_unmounted(const std::wstring &location) + [[nodiscard]] auto winfsp_unmounted(std::wstring_view location) -> packet::error_type override; [[nodiscard]] auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PUINT32 bytes_transferred, remote::file_info *file_info) + PUINT32 bytes_transferred, remote::file_info *r_info) -> packet::error_type override; }; } // namespace remote_winfsp diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp index 4da2c416..eb465f2b 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp @@ -70,9 +70,9 @@ private: std::string mount_location_; private: - void populate_file_info(const json &item, FSP_FSCTL_FILE_INFO &file_info); + void populate_file_info(const json &item, FSP_FSCTL_FILE_INFO &f_info); - static void set_file_info(FileInfo &dest, const remote::file_info &src); + static void set_file_info(FileInfo &f_info, const remote::file_info &r_info); public: auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name) @@ -88,10 +88,10 @@ public: UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS override; - auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) + auto Flush(PVOID file_node, PVOID file_desc, FileInfo *f_info) -> NTSTATUS override; - auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) + auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *f_info) -> NTSTATUS override; auto GetSecurityByName(PWSTR file_name, PUINT32 attributes, @@ -102,7 +102,10 @@ public: auto Init(PVOID host) -> NTSTATUS override; - [[nodiscard]] auto mount(const std::vector &drive_args) -> int; + [[nodiscard]] auto mount(std::vector orig_args, + std::vector drive_args, + provider_type prov, std::string_view unique_id) + -> int; auto Mounted(PVOID host) -> NTSTATUS override; @@ -112,7 +115,7 @@ public: auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, UINT64 allocation_size, - FileInfo *file_info) -> NTSTATUS override; + FileInfo *f_info) -> NTSTATUS override; auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, ULONG length, PULONG bytes_transferred) -> NTSTATUS override; @@ -128,18 +131,17 @@ public: auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, - FileInfo *file_info) -> NTSTATUS override; + FileInfo *f_info) -> NTSTATUS override; auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, FileInfo *file_info) + BOOLEAN set_allocation_size, FileInfo *f_info) -> NTSTATUS override; VOID Unmounted(PVOID host) override; auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PULONG bytes_transferred, FileInfo *file_info) - -> NTSTATUS override; + PULONG bytes_transferred, FileInfo *f_info) -> NTSTATUS override; void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); } diff --git a/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp index 4609f40d..0b88a29f 100644 --- a/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp @@ -77,23 +77,23 @@ private: private: [[nodiscard]] auto handle_error(std::string_view function_name, - const std::string &api_path, api_error error, - FileInfo *file_info, std::uint64_t file_size, + std::string_view api_path, api_error error, + FileInfo *f_info, std::uint64_t file_size, bool raise_on_failure_only = false) const -> NTSTATUS; - static auto parse_mount_location(const std::wstring &mount_location) + static auto parse_mount_location(std::wstring_view mount_location) -> std::string; - void populate_file_info(const std::string &api_path, std::uint64_t file_size, + void populate_file_info(std::string_view api_path, std::uint64_t file_size, const api_meta_map &meta, FSP_FSCTL_OPEN_FILE_INFO &ofi) const; void populate_file_info(std::uint64_t file_size, api_meta_map meta, FSP_FSCTL_FILE_INFO &fi) const; - static void set_file_info(remote::file_info &dest, - const FSP_FSCTL_FILE_INFO &src); + static void set_file_info(remote::file_info &r_info, + const FSP_FSCTL_FILE_INFO &f_info); void stop_all(); @@ -111,27 +111,27 @@ public: UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS override; - auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) + auto Flush(PVOID file_node, PVOID file_desc, FileInfo *f_info) -> NTSTATUS override; - [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const + [[nodiscard]] auto get_directory_item_count(std::string_view api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_directory_items(const std::string &api_path) const + [[nodiscard]] auto get_directory_items(std::string_view api_path) const -> directory_item_list override; - auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) + auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *f_info) -> NTSTATUS override; - [[nodiscard]] auto get_file_size(const std::string &api_path) const + [[nodiscard]] auto get_file_size(std::string_view api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, + [[nodiscard]] auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &name, + [[nodiscard]] auto get_item_meta(std::string_view api_path, + std::string_view name, std::string &value) const -> api_error override; @@ -157,7 +157,10 @@ public: auto Init(PVOID host) -> NTSTATUS override; - [[nodiscard]] auto mount(const std::vector &drive_args) -> int; + [[nodiscard]] auto mount(std::vector orig_args, + std::vector drive_args, + provider_type prov, std::string_view unique_id) + -> int; auto Mounted(PVOID host) -> NTSTATUS override; @@ -167,10 +170,10 @@ public: auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, UINT64 allocation_size, - FileInfo *file_info) -> NTSTATUS override; + FileInfo *f_info) -> NTSTATUS override; - [[nodiscard]] auto populate_file_info(const std::string &api_path, - remote::file_info &file_info) const + [[nodiscard]] auto populate_file_info(std::string_view api_path, + remote::file_info &r_info) const -> api_error override; auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, @@ -187,18 +190,17 @@ public: auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, - FileInfo *file_info) -> NTSTATUS override; + FileInfo *f_info) -> NTSTATUS override; auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, FileInfo *file_info) + BOOLEAN set_allocation_size, FileInfo *f_info) -> NTSTATUS override; VOID Unmounted(PVOID host) override; auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PULONG bytes_transferred, FileInfo *file_info) - -> NTSTATUS override; + PULONG bytes_transferred, FileInfo *f_info) -> NTSTATUS override; void shutdown(); diff --git a/repertory/librepertory/include/events/types/curl_error.hpp b/repertory/librepertory/include/events/types/curl_error.hpp index a255fd59..b2f0d3ea 100644 --- a/repertory/librepertory/include/events/types/curl_error.hpp +++ b/repertory/librepertory/include/events/types/curl_error.hpp @@ -28,12 +28,9 @@ namespace repertory { struct curl_error final : public i_event { curl_error() = default; - curl_error(CURLcode code_, std::string_view function_name_, std::string type_, - std::string url_) - : code(code_), - function_name(std::string{function_name_}), - type(std::move(type_)), - url(std::move(url_)) {} + curl_error(CURLcode code_, std::string_view function_name_, + std::string_view type_, std::string_view url_) + : code(code_), function_name(function_name_), type(type_), url(url_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{"curl_error"}; diff --git a/repertory/librepertory/include/events/types/debug_log.hpp b/repertory/librepertory/include/events/types/debug_log.hpp index 2642d003..acf08c3c 100644 --- a/repertory/librepertory/include/events/types/debug_log.hpp +++ b/repertory/librepertory/include/events/types/debug_log.hpp @@ -28,8 +28,8 @@ namespace repertory { struct debug_log final : public i_event { debug_log() = default; - debug_log(std::string_view function_name_, std::string msg_) - : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + debug_log(std::string_view function_name_, std::string_view msg_) + : function_name(function_name_), msg(msg_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"debug_log"}; diff --git a/repertory/librepertory/include/events/types/directory_remove_failed.hpp b/repertory/librepertory/include/events/types/directory_remove_failed.hpp index a044ed75..cd42a290 100644 --- a/repertory/librepertory/include/events/types/directory_remove_failed.hpp +++ b/repertory/librepertory/include/events/types/directory_remove_failed.hpp @@ -28,11 +28,9 @@ namespace repertory { struct directory_remove_failed final : public i_event { directory_remove_failed() = default; - directory_remove_failed(std::string api_path_, api_error error_, + directory_remove_failed(std::string_view api_path_, api_error error_, std::string_view function_name_) - : api_path(std::move(api_path_)), - error(error_), - function_name(std::string(function_name_)) {} + : api_path(api_path_), error(error_), function_name(function_name_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{"directory_remove_failed"}; diff --git a/repertory/librepertory/include/events/types/directory_removed.hpp b/repertory/librepertory/include/events/types/directory_removed.hpp index 922e7047..9e065342 100644 --- a/repertory/librepertory/include/events/types/directory_removed.hpp +++ b/repertory/librepertory/include/events/types/directory_removed.hpp @@ -28,9 +28,8 @@ namespace repertory { struct directory_removed final : public i_event { directory_removed() = default; - directory_removed(std::string api_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)) {} + directory_removed(std::string_view api_path_, std::string_view function_name_) + : api_path(api_path_), function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"directory_removed"}; diff --git a/repertory/librepertory/include/events/types/directory_removed_externally.hpp b/repertory/librepertory/include/events/types/directory_removed_externally.hpp index 95b87ae7..eac0dc5f 100644 --- a/repertory/librepertory/include/events/types/directory_removed_externally.hpp +++ b/repertory/librepertory/include/events/types/directory_removed_externally.hpp @@ -28,12 +28,12 @@ namespace repertory { struct directory_removed_externally final : public i_event { directory_removed_externally() = default; - directory_removed_externally(std::string api_path_, + directory_removed_externally(std::string_view api_path_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + std::string_view source_path_) + : api_path(api_path_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"directory_removed_externally"}; diff --git a/repertory/librepertory/include/events/types/download_begin.hpp b/repertory/librepertory/include/events/types/download_begin.hpp index 0fa3d3dd..b8c5c8d6 100644 --- a/repertory/librepertory/include/events/types/download_begin.hpp +++ b/repertory/librepertory/include/events/types/download_begin.hpp @@ -28,11 +28,11 @@ namespace repertory { struct download_begin final : public i_event { download_begin() = default; - download_begin(std::string api_path_, std::string dest_path_, + download_begin(std::string_view api_path_, std::string_view dest_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - function_name(std::string(function_name_)) {} + : api_path(api_path_), + dest_path(dest_path_), + function_name(function_name_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"download_begin"}; diff --git a/repertory/librepertory/include/events/types/download_end.hpp b/repertory/librepertory/include/events/types/download_end.hpp index e4cebe2d..abb4ffad 100644 --- a/repertory/librepertory/include/events/types/download_end.hpp +++ b/repertory/librepertory/include/events/types/download_end.hpp @@ -28,12 +28,12 @@ namespace repertory { struct download_end final : public i_event { download_end() = default; - download_end(std::string api_path_, std::string dest_path_, api_error error_, - std::string_view function_name_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), + download_end(std::string_view api_path_, std::string_view dest_path_, + api_error error_, std::string_view function_name_) + : api_path(api_path_), + dest_path(dest_path_), error(error_), - function_name(std::string(function_name_)) {} + function_name(function_name_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"download_end"}; diff --git a/repertory/librepertory/include/events/types/download_progress.hpp b/repertory/librepertory/include/events/types/download_progress.hpp index 1361ef19..2cc82384 100644 --- a/repertory/librepertory/include/events/types/download_progress.hpp +++ b/repertory/librepertory/include/events/types/download_progress.hpp @@ -28,11 +28,11 @@ namespace repertory { struct download_progress final : public i_event { download_progress() = default; - download_progress(std::string api_path_, std::string dest_path_, + download_progress(std::string_view api_path_, std::string_view dest_path_, std::string_view function_name_, double progress_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - function_name(std::string(function_name_)), + : api_path(api_path_), + dest_path(dest_path_), + function_name(function_name_), progress(progress_) {} static constexpr event_level level{event_level::info}; diff --git a/repertory/librepertory/include/events/types/download_restore_failed.hpp b/repertory/librepertory/include/events/types/download_restore_failed.hpp index 2c834967..739bf1ac 100644 --- a/repertory/librepertory/include/events/types/download_restore_failed.hpp +++ b/repertory/librepertory/include/events/types/download_restore_failed.hpp @@ -28,12 +28,13 @@ namespace repertory { struct download_restore_failed final : public i_event { download_restore_failed() = default; - download_restore_failed(std::string api_path_, std::string dest_path_, - std::string error_, std::string_view function_name_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - error(std::move(error_)), - function_name(std::string(function_name_)) {} + download_restore_failed(std::string_view api_path_, + std::string_view dest_path_, std::string_view error_, + std::string_view function_name_) + : api_path(api_path_), + dest_path(dest_path_), + error(error_), + function_name(function_name_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{"download_restore_failed"}; diff --git a/repertory/librepertory/include/events/types/download_restored.hpp b/repertory/librepertory/include/events/types/download_restored.hpp index 67536cf4..22214744 100644 --- a/repertory/librepertory/include/events/types/download_restored.hpp +++ b/repertory/librepertory/include/events/types/download_restored.hpp @@ -28,11 +28,11 @@ namespace repertory { struct download_restored final : public i_event { download_restored() = default; - download_restored(std::string api_path_, std::string dest_path_, + download_restored(std::string_view api_path_, std::string_view dest_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - function_name(std::string(function_name_)) {} + : api_path(api_path_), + dest_path(dest_path_), + function_name(function_name_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"download_restored"}; diff --git a/repertory/librepertory/include/events/types/download_resume_add_failed.hpp b/repertory/librepertory/include/events/types/download_resume_add_failed.hpp index 7741caa6..96e090ad 100644 --- a/repertory/librepertory/include/events/types/download_resume_add_failed.hpp +++ b/repertory/librepertory/include/events/types/download_resume_add_failed.hpp @@ -28,13 +28,14 @@ namespace repertory { struct download_resume_add_failed final : public i_event { download_resume_add_failed() = default; - download_resume_add_failed(std::string api_path_, std::string dest_path_, - std::string error_, + download_resume_add_failed(std::string_view api_path_, + std::string_view dest_path_, + std::string_view error_, std::string_view function_name_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - error(std::move(error_)), - function_name(std::string(function_name_)) {} + : api_path(api_path_), + dest_path(dest_path_), + error(error_), + function_name(function_name_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{"download_resume_add_failed"}; diff --git a/repertory/librepertory/include/events/types/download_resume_added.hpp b/repertory/librepertory/include/events/types/download_resume_added.hpp index a2935079..c49af159 100644 --- a/repertory/librepertory/include/events/types/download_resume_added.hpp +++ b/repertory/librepertory/include/events/types/download_resume_added.hpp @@ -28,11 +28,11 @@ namespace repertory { struct download_resume_added final : public i_event { download_resume_added() = default; - download_resume_added(std::string api_path_, std::string dest_path_, + download_resume_added(std::string_view api_path_, std::string_view dest_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - function_name(std::string(function_name_)) {} + : api_path(api_path_), + dest_path(dest_path_), + function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"download_resume_added"}; diff --git a/repertory/librepertory/include/events/types/download_resume_removed.hpp b/repertory/librepertory/include/events/types/download_resume_removed.hpp index 0ea3c0d9..aabd62d4 100644 --- a/repertory/librepertory/include/events/types/download_resume_removed.hpp +++ b/repertory/librepertory/include/events/types/download_resume_removed.hpp @@ -28,11 +28,12 @@ namespace repertory { struct download_resume_removed final : public i_event { download_resume_removed() = default; - download_resume_removed(std::string api_path_, std::string dest_path_, + download_resume_removed(std::string_view api_path_, + std::string_view dest_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - function_name(std::string(function_name_)) {} + : api_path(api_path_), + dest_path(dest_path_), + function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"download_resume_removed"}; diff --git a/repertory/librepertory/include/events/types/download_type_selected.hpp b/repertory/librepertory/include/events/types/download_type_selected.hpp index 92d15978..15a3595d 100644 --- a/repertory/librepertory/include/events/types/download_type_selected.hpp +++ b/repertory/librepertory/include/events/types/download_type_selected.hpp @@ -28,11 +28,12 @@ namespace repertory { struct download_type_selected final : public i_event { download_type_selected() = default; - download_type_selected(std::string api_path_, std::string dest_path_, + download_type_selected(std::string_view api_path_, + std::string_view dest_path_, std::string_view function_name_, download_type type_) - : api_path(std::move(api_path_)), - dest_path(std::move(dest_path_)), - function_name(std::string(function_name_)), + : api_path(api_path_), + dest_path(dest_path_), + function_name(function_name_), type(type_) {} static constexpr event_level level{event_level::debug}; diff --git a/repertory/librepertory/include/events/types/drive_mount_failed.hpp b/repertory/librepertory/include/events/types/drive_mount_failed.hpp index ad76e9e0..e28dbdb3 100644 --- a/repertory/librepertory/include/events/types/drive_mount_failed.hpp +++ b/repertory/librepertory/include/events/types/drive_mount_failed.hpp @@ -30,9 +30,9 @@ namespace repertory { struct drive_mount_failed final : public i_event { drive_mount_failed() = default; drive_mount_failed(NTSTATUS error_, std::string_view function_name_, - std::string mount_location_) + std::string_view mount_location_) : error(error_), - function_name(std::string(function_name_)), + function_name(function_name_), mount_location(std::move(mount_location_)) {} static constexpr event_level level{event_level::error}; diff --git a/repertory/librepertory/include/events/types/drive_mount_result.hpp b/repertory/librepertory/include/events/types/drive_mount_result.hpp index ada57745..4d4d49bf 100644 --- a/repertory/librepertory/include/events/types/drive_mount_result.hpp +++ b/repertory/librepertory/include/events/types/drive_mount_result.hpp @@ -29,10 +29,10 @@ namespace repertory { struct drive_mount_result final : public i_event { drive_mount_result() = default; drive_mount_result(std::string_view function_name_, - std::string mount_location_, std::string result_) - : function_name(std::string(function_name_)), - mount_location(std::move(mount_location_)), - result(std::move(result_)) {} + std::string_view mount_location_, std::string result_) + : function_name(function_name_), + mount_location(mount_location_), + result(result_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"drive_mount_result"}; diff --git a/repertory/librepertory/include/events/types/drive_mounted.hpp b/repertory/librepertory/include/events/types/drive_mounted.hpp index 67c7c07d..92b115cb 100644 --- a/repertory/librepertory/include/events/types/drive_mounted.hpp +++ b/repertory/librepertory/include/events/types/drive_mounted.hpp @@ -28,9 +28,9 @@ namespace repertory { struct drive_mounted final : public i_event { drive_mounted() = default; - drive_mounted(std::string_view function_name_, std::string mount_location_) - : function_name(std::string(function_name_)), - mount_location(std::move(mount_location_)) {} + drive_mounted(std::string_view function_name_, + std::string_view mount_location_) + : function_name(function_name_), mount_location(mount_location_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"drive_mounted"}; diff --git a/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp b/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp index 4f54f7e1..03061bc7 100644 --- a/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp +++ b/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp @@ -29,7 +29,7 @@ namespace repertory { struct drive_stop_timed_out final : public i_event { drive_stop_timed_out() = default; drive_stop_timed_out(std::string_view function_name_) - : function_name(std::string(function_name_)) {} + : function_name(function_name_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"drive_stop_timed_out"}; diff --git a/repertory/librepertory/include/events/types/drive_unmount_pending.hpp b/repertory/librepertory/include/events/types/drive_unmount_pending.hpp index 75162598..fba886cd 100644 --- a/repertory/librepertory/include/events/types/drive_unmount_pending.hpp +++ b/repertory/librepertory/include/events/types/drive_unmount_pending.hpp @@ -29,9 +29,8 @@ namespace repertory { struct drive_unmount_pending final : public i_event { drive_unmount_pending() = default; drive_unmount_pending(std::string_view function_name_, - std::string mount_location_) - : function_name(std::string(function_name_)), - mount_location(std::move(mount_location_)) {} + std::string_view mount_location_) + : function_name(function_name_), mount_location(mount_location_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"drive_unmount_pending"}; diff --git a/repertory/librepertory/include/events/types/drive_unmounted.hpp b/repertory/librepertory/include/events/types/drive_unmounted.hpp index e9d69aad..e14e20df 100644 --- a/repertory/librepertory/include/events/types/drive_unmounted.hpp +++ b/repertory/librepertory/include/events/types/drive_unmounted.hpp @@ -28,9 +28,9 @@ namespace repertory { struct drive_unmounted final : public i_event { drive_unmounted() = default; - drive_unmounted(std::string_view function_name_, std::string mount_location_) - : function_name(std::string(function_name_)), - mount_location(std::move(mount_location_)) {} + drive_unmounted(std::string_view function_name_, + std::string_view mount_location_) + : function_name(function_name_), mount_location(mount_location_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"drive_unmounted"}; diff --git a/repertory/librepertory/include/events/types/event_level_changed.hpp b/repertory/librepertory/include/events/types/event_level_changed.hpp index aca9122b..5d77bc1c 100644 --- a/repertory/librepertory/include/events/types/event_level_changed.hpp +++ b/repertory/librepertory/include/events/types/event_level_changed.hpp @@ -29,7 +29,7 @@ namespace repertory { struct event_level_changed final : public i_event { event_level_changed() = default; event_level_changed(std::string_view function_name_, event_level new_level_) - : function_name(std::string(function_name_)), new_level(new_level_) {} + : function_name(function_name_), new_level(new_level_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"event_level_changed"}; diff --git a/repertory/librepertory/include/events/types/file_pinned.hpp b/repertory/librepertory/include/events/types/file_pinned.hpp index fdc742a8..879e4ab1 100644 --- a/repertory/librepertory/include/events/types/file_pinned.hpp +++ b/repertory/librepertory/include/events/types/file_pinned.hpp @@ -28,9 +28,8 @@ namespace repertory { struct file_pinned final : public i_event { file_pinned() = default; - file_pinned(std::string api_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)) {} + file_pinned(std::string_view api_path_, std::string_view function_name_) + : api_path(api_path_), function_name(function_name_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"file_pinned"}; diff --git a/repertory/librepertory/include/events/types/file_remove_failed.hpp b/repertory/librepertory/include/events/types/file_remove_failed.hpp index 37c2c6f3..ae216b25 100644 --- a/repertory/librepertory/include/events/types/file_remove_failed.hpp +++ b/repertory/librepertory/include/events/types/file_remove_failed.hpp @@ -28,11 +28,9 @@ namespace repertory { struct file_remove_failed final : public i_event { file_remove_failed() = default; - file_remove_failed(std::string api_path_, api_error error_, + file_remove_failed(std::string_view api_path_, api_error error_, std::string_view function_name_) - : api_path(std::move(api_path_)), - error(error_), - function_name(std::string(function_name_)) {} + : api_path(api_path_), error(error_), function_name(function_name_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{"file_remove_failed"}; diff --git a/repertory/librepertory/include/events/types/file_removed.hpp b/repertory/librepertory/include/events/types/file_removed.hpp index b1156b8b..5acb4765 100644 --- a/repertory/librepertory/include/events/types/file_removed.hpp +++ b/repertory/librepertory/include/events/types/file_removed.hpp @@ -28,9 +28,8 @@ namespace repertory { struct file_removed final : public i_event { file_removed() = default; - file_removed(std::string api_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)) {} + file_removed(std::string_view api_path_, std::string_view function_name_) + : api_path(api_path_), function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"file_removed"}; diff --git a/repertory/librepertory/include/events/types/file_removed_externally.hpp b/repertory/librepertory/include/events/types/file_removed_externally.hpp index 079f3110..1d277410 100644 --- a/repertory/librepertory/include/events/types/file_removed_externally.hpp +++ b/repertory/librepertory/include/events/types/file_removed_externally.hpp @@ -28,12 +28,12 @@ namespace repertory { struct file_removed_externally final : public i_event { file_removed_externally() = default; - file_removed_externally(std::string api_path_, + file_removed_externally(std::string_view api_path_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + std::string_view source_path_) + : api_path(api_path_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"file_removed_externally"}; diff --git a/repertory/librepertory/include/events/types/file_unpinned.hpp b/repertory/librepertory/include/events/types/file_unpinned.hpp index eb3b629f..3f53eefb 100644 --- a/repertory/librepertory/include/events/types/file_unpinned.hpp +++ b/repertory/librepertory/include/events/types/file_unpinned.hpp @@ -28,9 +28,8 @@ namespace repertory { struct file_unpinned final : public i_event { file_unpinned() = default; - file_unpinned(std::string api_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)) {} + file_unpinned(std::string_view api_path_, std::string_view function_name_) + : api_path(api_path_), function_name(function_name_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"file_unpinned"}; diff --git a/repertory/librepertory/include/events/types/file_upload_completed.hpp b/repertory/librepertory/include/events/types/file_upload_completed.hpp index 3ecb7766..ad22ef4b 100644 --- a/repertory/librepertory/include/events/types/file_upload_completed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_completed.hpp @@ -28,14 +28,14 @@ namespace repertory { struct file_upload_completed final : public i_event { file_upload_completed() = default; - file_upload_completed(std::string api_path_, bool cancelled_, + file_upload_completed(std::string_view api_path_, bool cancelled_, api_error error_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), + std::string_view source_path_) + : api_path(api_path_), cancelled(cancelled_), error(error_), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"file_upload_completed"}; diff --git a/repertory/librepertory/include/events/types/file_upload_failed.hpp b/repertory/librepertory/include/events/types/file_upload_failed.hpp index 93800b8c..66eeca76 100644 --- a/repertory/librepertory/include/events/types/file_upload_failed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_failed.hpp @@ -28,12 +28,13 @@ namespace repertory { struct file_upload_failed final : public i_event { file_upload_failed() = default; - file_upload_failed(std::string api_path_, std::string error_, - std::string_view function_name_, std::string source_path_) - : api_path(std::move(api_path_)), - error(std::move(error_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + file_upload_failed(std::string_view api_path_, std::string_view error_, + std::string_view function_name_, + std::string_view source_path_) + : api_path(api_path_), + error(error_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"file_upload_failed"}; diff --git a/repertory/librepertory/include/events/types/file_upload_not_found.hpp b/repertory/librepertory/include/events/types/file_upload_not_found.hpp index 1b74330e..5e076727 100644 --- a/repertory/librepertory/include/events/types/file_upload_not_found.hpp +++ b/repertory/librepertory/include/events/types/file_upload_not_found.hpp @@ -28,11 +28,12 @@ namespace repertory { struct file_upload_not_found final : public i_event { file_upload_not_found() = default; - file_upload_not_found(std::string api_path_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + file_upload_not_found(std::string_view api_path_, + std::string_view function_name_, + std::string_view source_path_) + : api_path(api_path_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"file_upload_not_found"}; diff --git a/repertory/librepertory/include/events/types/file_upload_queued.hpp b/repertory/librepertory/include/events/types/file_upload_queued.hpp index 41949302..cd4af05c 100644 --- a/repertory/librepertory/include/events/types/file_upload_queued.hpp +++ b/repertory/librepertory/include/events/types/file_upload_queued.hpp @@ -28,11 +28,12 @@ namespace repertory { struct file_upload_queued final : public i_event { file_upload_queued() = default; - file_upload_queued(std::string api_path_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + file_upload_queued(std::string_view api_path_, + std::string_view function_name_, + std::string_view source_path_) + : api_path(api_path_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"file_upload_queued"}; diff --git a/repertory/librepertory/include/events/types/file_upload_removed.hpp b/repertory/librepertory/include/events/types/file_upload_removed.hpp index 04ba865e..c7406a7a 100644 --- a/repertory/librepertory/include/events/types/file_upload_removed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_removed.hpp @@ -28,9 +28,9 @@ namespace repertory { struct file_upload_removed final : public i_event { file_upload_removed() = default; - file_upload_removed(std::string api_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)) {} + file_upload_removed(std::string_view api_path_, + std::string_view function_name_) + : api_path(api_path_), function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"file_upload_removed"}; diff --git a/repertory/librepertory/include/events/types/file_upload_retry.hpp b/repertory/librepertory/include/events/types/file_upload_retry.hpp index 7296a364..44a4e09a 100644 --- a/repertory/librepertory/include/events/types/file_upload_retry.hpp +++ b/repertory/librepertory/include/events/types/file_upload_retry.hpp @@ -28,12 +28,13 @@ namespace repertory { struct file_upload_retry final : public i_event { file_upload_retry() = default; - file_upload_retry(std::string api_path_, api_error error_, - std::string_view function_name_, std::string source_path_) - : api_path(std::move(api_path_)), - error(std::move(error_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + file_upload_retry(std::string_view api_path_, api_error error_, + std::string_view function_name_, + std::string_view source_path_) + : api_path(api_path_), + error(error_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"file_upload_retry"}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_added.hpp b/repertory/librepertory/include/events/types/filesystem_item_added.hpp index 853da92b..eb30e23f 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_added.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_added.hpp @@ -28,12 +28,13 @@ namespace repertory { struct filesystem_item_added final : public i_event { filesystem_item_added() = default; - filesystem_item_added(std::string api_parent_, std::string api_path_, - bool directory_, std::string_view function_name_) - : api_parent(std::move(api_parent_)), - api_path(std::move(api_path_)), + filesystem_item_added(std::string_view api_parent_, + std::string_view api_path_, bool directory_, + std::string_view function_name_) + : api_parent(api_parent_), + api_path(api_path_), directory(directory_), - function_name(std::string(function_name_)) {} + function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"filesystem_item_added"}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp index b5d1340c..4946bfe2 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_closed.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp @@ -28,14 +28,14 @@ namespace repertory { struct filesystem_item_closed final : public i_event { filesystem_item_closed() = default; - filesystem_item_closed(std::string api_path_, bool changed_, bool directory_, - std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), + filesystem_item_closed(std::string_view api_path_, bool changed_, + bool directory_, std::string_view function_name_, + std::string_view source_path_) + : api_path(api_path_), changed(changed_), directory(directory_), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::trace}; static constexpr std::string_view name{"filesystem_item_closed"}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp index 5821d896..d08f226f 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp @@ -28,12 +28,12 @@ namespace repertory { struct filesystem_item_evicted final : public i_event { filesystem_item_evicted() = default; - filesystem_item_evicted(std::string api_path_, + filesystem_item_evicted(std::string_view api_path_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + std::string_view source_path_) + : api_path(api_path_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"filesystem_item_evicted"}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp index b84627d9..b07f3c6f 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp @@ -28,16 +28,17 @@ namespace repertory { struct filesystem_item_handle_closed final : public i_event { filesystem_item_handle_closed() = default; - filesystem_item_handle_closed(std::string api_path_, bool changed_, + filesystem_item_handle_closed(std::string_view api_path_, bool changed_, bool directory_, std::string_view function_name_, - std::uint64_t handle_, std::string source_path_) - : api_path(std::move(api_path_)), + std::uint64_t handle_, + std::string_view source_path_) + : api_path(api_path_), changed(changed_), directory(directory_), - function_name(std::string(function_name_)), + function_name(function_name_), handle(handle_), - source_path(std::move(source_path_)) {} + source_path(source_path_) {} static constexpr event_level level{event_level::trace}; static constexpr std::string_view name{"filesystem_item_handle_closed"}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp index 0ea6f0ad..d24a565b 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp @@ -28,14 +28,15 @@ namespace repertory { struct filesystem_item_handle_opened final : public i_event { filesystem_item_handle_opened() = default; - filesystem_item_handle_opened(std::string api_path_, bool directory_, + filesystem_item_handle_opened(std::string_view api_path_, bool directory_, std::string_view function_name_, - std::uint64_t handle_, std::string source_path_) - : api_path(std::move(api_path_)), + std::uint64_t handle_, + std::string_view source_path_) + : api_path(api_path_), directory(directory_), - function_name(std::string(function_name_)), + function_name(function_name_), handle(handle_), - source_path(std::move(source_path_)) {} + source_path(source_path_) {} static constexpr event_level level{event_level::trace}; static constexpr std::string_view name{"filesystem_item_handle_opened"}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp index 5d19f839..d9d44e93 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_opened.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp @@ -28,13 +28,13 @@ namespace repertory { struct filesystem_item_opened final : public i_event { filesystem_item_opened() = default; - filesystem_item_opened(std::string api_path_, bool directory_, + filesystem_item_opened(std::string_view api_path_, bool directory_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), + std::string_view source_path_) + : api_path(api_path_), directory(directory_), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::trace}; static constexpr std::string_view name{"filesystem_item_opened"}; diff --git a/repertory/librepertory/include/events/types/fuse_args_parsed.hpp b/repertory/librepertory/include/events/types/fuse_args_parsed.hpp index 795bf4e5..e03c387c 100644 --- a/repertory/librepertory/include/events/types/fuse_args_parsed.hpp +++ b/repertory/librepertory/include/events/types/fuse_args_parsed.hpp @@ -30,7 +30,7 @@ namespace repertory { struct fuse_args_parsed final : public i_event { fuse_args_parsed() = default; fuse_args_parsed(std::string_view args_, std::string_view function_name_) - : args(std::move(args_)), function_name(std::string{function_name_}) {} + : args(args_), function_name(function_name_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"fuse_args_parsed"}; diff --git a/repertory/librepertory/include/events/types/fuse_event.hpp b/repertory/librepertory/include/events/types/fuse_event.hpp index a1f717ce..68679022 100644 --- a/repertory/librepertory/include/events/types/fuse_event.hpp +++ b/repertory/librepertory/include/events/types/fuse_event.hpp @@ -31,9 +31,7 @@ struct fuse_event final : public i_event { fuse_event() = default; fuse_event(std::string_view api_path_, std::int32_t error_, std::string_view function_name_) - : api_path(std::string{api_path_}), - error(error_), - function_name(std::string{function_name_}) {} + : api_path(api_path_), error(error_), function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"fuse_event"}; diff --git a/repertory/librepertory/include/events/types/info_log.hpp b/repertory/librepertory/include/events/types/info_log.hpp index 36e1e1cb..60653451 100644 --- a/repertory/librepertory/include/events/types/info_log.hpp +++ b/repertory/librepertory/include/events/types/info_log.hpp @@ -28,8 +28,8 @@ namespace repertory { struct info_log final : public i_event { info_log() = default; - info_log(std::string_view function_name_, std::string msg_) - : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + info_log(std::string_view function_name_, std::string_view msg_) + : function_name(function_name_), msg(msg_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"info_log"}; diff --git a/repertory/librepertory/include/events/types/invalid_cache_size.hpp b/repertory/librepertory/include/events/types/invalid_cache_size.hpp index b6f21ab7..f059c33d 100644 --- a/repertory/librepertory/include/events/types/invalid_cache_size.hpp +++ b/repertory/librepertory/include/events/types/invalid_cache_size.hpp @@ -31,7 +31,7 @@ struct invalid_cache_size final : public i_event { invalid_cache_size(std::uint64_t cache_size_, std::string_view function_name_, std::uint64_t invalid_size_) : cache_size(cache_size_), - function_name(std::string{function_name_}), + function_name(function_name_), invalid_size(invalid_size_) {} static constexpr event_level level{event_level::warn}; diff --git a/repertory/librepertory/include/events/types/item_timeout.hpp b/repertory/librepertory/include/events/types/item_timeout.hpp index ac128a16..3da5898a 100644 --- a/repertory/librepertory/include/events/types/item_timeout.hpp +++ b/repertory/librepertory/include/events/types/item_timeout.hpp @@ -28,9 +28,8 @@ namespace repertory { struct item_timeout final : public i_event { item_timeout() = default; - item_timeout(std::string api_path_, std::string_view function_name_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)) {} + item_timeout(std::string_view api_path_, std::string_view function_name_) + : api_path(api_path_), function_name(function_name_) {} static constexpr event_level level{event_level::trace}; static constexpr std::string_view name{"item_timeout"}; diff --git a/repertory/librepertory/include/events/types/max_cache_size_reached.hpp b/repertory/librepertory/include/events/types/max_cache_size_reached.hpp index 3da04e59..d8e26972 100644 --- a/repertory/librepertory/include/events/types/max_cache_size_reached.hpp +++ b/repertory/librepertory/include/events/types/max_cache_size_reached.hpp @@ -32,7 +32,7 @@ struct max_cache_size_reached final : public i_event { std::string_view function_name_, std::uint64_t max_cache_size_) : cache_size(cache_size_), - function_name(std::string{function_name_}), + function_name(function_name_), max_cache_size(max_cache_size_) {} static constexpr event_level level{event_level::warn}; diff --git a/repertory/librepertory/include/events/types/orphaned_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp index d299a0a5..644363fc 100644 --- a/repertory/librepertory/include/events/types/orphaned_file_detected.hpp +++ b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp @@ -29,9 +29,8 @@ namespace repertory { struct orphaned_file_detected final : public i_event { orphaned_file_detected() = default; orphaned_file_detected(std::string_view function_name_, - std::string source_path_) - : function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + std::string_view source_path_) + : function_name(function_name_), source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"orphaned_file_detected"}; diff --git a/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp index 9476a972..3be9d9c7 100644 --- a/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp +++ b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp @@ -28,13 +28,14 @@ namespace repertory { struct orphaned_file_processing_failed final : public i_event { orphaned_file_processing_failed() = default; - orphaned_file_processing_failed(std::string dest_path_, std::string error_, + orphaned_file_processing_failed(std::string_view dest_path_, + std::string_view error_, std::string_view function_name_, - std::string source_path_) - : dest_path(std::move(dest_path_)), - error(std::move(error_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + std::string_view source_path_) + : dest_path(dest_path_), + error(error_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{ diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp index 14aeb11a..bcee6f6a 100644 --- a/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp +++ b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp @@ -29,9 +29,8 @@ namespace repertory { struct orphaned_source_file_detected final : public i_event { orphaned_source_file_detected() = default; orphaned_source_file_detected(std::string_view function_name_, - std::string source_path_) - : function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + std::string_view source_path_) + : function_name(function_name_), source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"orphaned_source_file_detected"}; diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp index 22d81529..dfcf3fb3 100644 --- a/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp +++ b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp @@ -29,9 +29,8 @@ namespace repertory { struct orphaned_source_file_removed final : public i_event { orphaned_source_file_removed() = default; orphaned_source_file_removed(std::string_view function_name_, - std::string source_path_) - : function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + std::string_view source_path_) + : function_name(function_name_), source_path(source_path_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"orphaned_source_file_removed"}; diff --git a/repertory/librepertory/include/events/types/packet_client_timeout.hpp b/repertory/librepertory/include/events/types/packet_client_timeout.hpp index 1c36b242..f87fddad 100644 --- a/repertory/librepertory/include/events/types/packet_client_timeout.hpp +++ b/repertory/librepertory/include/events/types/packet_client_timeout.hpp @@ -28,11 +28,9 @@ namespace repertory { struct packet_client_timeout final : public i_event { packet_client_timeout() = default; - packet_client_timeout(std::string event_name_, - std::string_view function_name_, std::string msg_) - : event_name(std::move(event_name_)), - function_name(std::string(function_name_)), - msg(std::move(msg_)) {} + packet_client_timeout(std::string_view event_name_, + std::string_view function_name_) + : event_name(event_name_), function_name(function_name_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"packet_client_timeout"}; @@ -50,8 +48,7 @@ struct packet_client_timeout final : public i_event { } [[nodiscard]] auto get_single_line() const -> std::string override { - return fmt::format("{}|func|{}|event|{}|msg|{}", name, function_name, - event_name, msg); + return fmt::format("{}|func|{}|event|{}", name, function_name, event_name); } }; } // namespace repertory @@ -62,14 +59,12 @@ template <> struct adl_serializer { const repertory::packet_client_timeout &value) { data["event_name"] = value.event_name; data["function_name"] = value.function_name; - data["msg"] = value.msg; } static void from_json(const json &data, repertory::packet_client_timeout &value) { data.at("event_name").get_to(value.event_name); data.at("function_name").get_to(value.function_name); - data.at("msg").get_to(value.msg); } }; NLOHMANN_JSON_NAMESPACE_END diff --git a/repertory/librepertory/include/events/types/polling_item_begin.hpp b/repertory/librepertory/include/events/types/polling_item_begin.hpp index fd98cbe5..7e496f3d 100644 --- a/repertory/librepertory/include/events/types/polling_item_begin.hpp +++ b/repertory/librepertory/include/events/types/polling_item_begin.hpp @@ -28,9 +28,9 @@ namespace repertory { struct polling_item_begin final : public i_event { polling_item_begin() = default; - polling_item_begin(std::string_view function_name_, std::string item_name_) - : function_name(std::string(function_name_)), - item_name(std::move(item_name_)) {} + polling_item_begin(std::string_view function_name_, + std::string_view item_name_) + : function_name(function_name_), item_name(item_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"polling_item_begin"}; diff --git a/repertory/librepertory/include/events/types/polling_item_end.hpp b/repertory/librepertory/include/events/types/polling_item_end.hpp index 5bc6075e..8446e31c 100644 --- a/repertory/librepertory/include/events/types/polling_item_end.hpp +++ b/repertory/librepertory/include/events/types/polling_item_end.hpp @@ -28,9 +28,8 @@ namespace repertory { struct polling_item_end final : public i_event { polling_item_end() = default; - polling_item_end(std::string_view function_name_, std::string item_name_) - : function_name(std::string(function_name_)), - item_name(std::move(item_name_)) {} + polling_item_end(std::string_view function_name_, std::string_view item_name_) + : function_name(function_name_), item_name(item_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"polling_item_end"}; diff --git a/repertory/librepertory/include/events/types/provider_invalid_version.hpp b/repertory/librepertory/include/events/types/provider_invalid_version.hpp index cc6e84b0..df26c3f9 100644 --- a/repertory/librepertory/include/events/types/provider_invalid_version.hpp +++ b/repertory/librepertory/include/events/types/provider_invalid_version.hpp @@ -29,11 +29,11 @@ namespace repertory { struct provider_invalid_version final : public i_event { provider_invalid_version() = default; provider_invalid_version(std::string_view function_name_, - std::string required_version_, - std::string returned_version_) - : function_name(std::string(function_name_)), - required_version(std::move(required_version_)), - returned_version(std::move(returned_version_)) {} + std::string_view required_version_, + std::string_view returned_version_) + : function_name(function_name_), + required_version(required_version_), + returned_version(returned_version_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{"provider_invalid_version"}; diff --git a/repertory/librepertory/include/events/types/provider_offline.hpp b/repertory/librepertory/include/events/types/provider_offline.hpp index e1f3b82e..72512da3 100644 --- a/repertory/librepertory/include/events/types/provider_offline.hpp +++ b/repertory/librepertory/include/events/types/provider_offline.hpp @@ -29,9 +29,9 @@ namespace repertory { struct provider_offline final : public i_event { provider_offline() = default; provider_offline(std::string_view function_name_, - std::string host_name_or_ip_, std::uint16_t port_) - : function_name(std::string(function_name_)), - host_name_or_ip(std::move(host_name_or_ip_)), + std::string_view host_name_or_ip_, std::uint16_t port_) + : function_name(function_name_), + host_name_or_ip(host_name_or_ip_), port(port_) {} static constexpr event_level level{event_level::warn}; diff --git a/repertory/librepertory/include/events/types/provider_upload_begin.hpp b/repertory/librepertory/include/events/types/provider_upload_begin.hpp index 5a7fc5e2..6872c868 100644 --- a/repertory/librepertory/include/events/types/provider_upload_begin.hpp +++ b/repertory/librepertory/include/events/types/provider_upload_begin.hpp @@ -28,11 +28,12 @@ namespace repertory { struct provider_upload_begin final : public i_event { provider_upload_begin() = default; - provider_upload_begin(std::string api_path_, std::string_view function_name_, - std::string source_path_) - : api_path(std::move(api_path_)), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + provider_upload_begin(std::string_view api_path_, + std::string_view function_name_, + std::string_view source_path_) + : api_path(api_path_), + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"provider_upload_begin"}; diff --git a/repertory/librepertory/include/events/types/provider_upload_end.hpp b/repertory/librepertory/include/events/types/provider_upload_end.hpp index 7e69118a..4cfd62d4 100644 --- a/repertory/librepertory/include/events/types/provider_upload_end.hpp +++ b/repertory/librepertory/include/events/types/provider_upload_end.hpp @@ -28,12 +28,13 @@ namespace repertory { struct provider_upload_end final : public i_event { provider_upload_end() = default; - provider_upload_end(std::string api_path_, api_error error_, - std::string_view function_name_, std::string source_path_) - : api_path(std::move(api_path_)), + provider_upload_end(std::string_view api_path_, api_error error_, + std::string_view function_name_, + std::string_view source_path_) + : api_path(api_path_), error(error_), - function_name(std::string(function_name_)), - source_path(std::move(source_path_)) {} + function_name(function_name_), + source_path(source_path_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"provider_upload_end"}; diff --git a/repertory/librepertory/include/events/types/remote_server_event.hpp b/repertory/librepertory/include/events/types/remote_server_event.hpp index d13d368a..45547772 100644 --- a/repertory/librepertory/include/events/types/remote_server_event.hpp +++ b/repertory/librepertory/include/events/types/remote_server_event.hpp @@ -29,11 +29,9 @@ namespace repertory { struct remote_server_event final : public i_event { remote_server_event() = default; - remote_server_event(std::string api_path_, packet::error_type error_, + remote_server_event(std::string_view api_path_, packet::error_type error_, std::string_view function_name_) - : api_path(std::move(api_path_)), - error(error_), - function_name(std::string{function_name_}) {} + : api_path(api_path_), error(error_), function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"remote_server_event"}; diff --git a/repertory/librepertory/include/events/types/repertory_exception.hpp b/repertory/librepertory/include/events/types/repertory_exception.hpp index 6b901ec7..39847b53 100644 --- a/repertory/librepertory/include/events/types/repertory_exception.hpp +++ b/repertory/librepertory/include/events/types/repertory_exception.hpp @@ -28,8 +28,8 @@ namespace repertory { struct repertory_exception final : public i_event { repertory_exception() = default; - repertory_exception(std::string_view function_name_, std::string msg_) - : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + repertory_exception(std::string_view function_name_, std::string_view msg_) + : function_name(function_name_), msg(msg_) {} static constexpr event_level level{event_level::error}; static constexpr std::string_view name{"repertory_exception"}; diff --git a/repertory/librepertory/include/events/types/service_start_begin.hpp b/repertory/librepertory/include/events/types/service_start_begin.hpp index 384c437a..303acc3f 100644 --- a/repertory/librepertory/include/events/types/service_start_begin.hpp +++ b/repertory/librepertory/include/events/types/service_start_begin.hpp @@ -29,9 +29,8 @@ namespace repertory { struct service_start_begin final : public i_event { service_start_begin() = default; service_start_begin(std::string_view function_name_, - std::string service_name_) - : function_name(std::string(function_name_)), - service_name(std::move(service_name_)) {} + std::string_view service_name_) + : function_name(function_name_), service_name(service_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"service_start_begin"}; diff --git a/repertory/librepertory/include/events/types/service_start_end.hpp b/repertory/librepertory/include/events/types/service_start_end.hpp index 470bdddd..ee559c64 100644 --- a/repertory/librepertory/include/events/types/service_start_end.hpp +++ b/repertory/librepertory/include/events/types/service_start_end.hpp @@ -28,9 +28,9 @@ namespace repertory { struct service_start_end final : public i_event { service_start_end() = default; - service_start_end(std::string_view function_name_, std::string service_name_) - : function_name(std::string(function_name_)), - service_name(std::move(service_name_)) {} + service_start_end(std::string_view function_name_, + std::string_view service_name_) + : function_name(function_name_), service_name(std::move(service_name_)) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"service_start_end"}; diff --git a/repertory/librepertory/include/events/types/service_stop_begin.hpp b/repertory/librepertory/include/events/types/service_stop_begin.hpp index 8b41a6f1..ce28c63a 100644 --- a/repertory/librepertory/include/events/types/service_stop_begin.hpp +++ b/repertory/librepertory/include/events/types/service_stop_begin.hpp @@ -28,9 +28,9 @@ namespace repertory { struct service_stop_begin final : public i_event { service_stop_begin() = default; - service_stop_begin(std::string_view function_name_, std::string service_name_) - : function_name(std::string(function_name_)), - service_name(std::move(service_name_)) {} + service_stop_begin(std::string_view function_name_, + std::string_view service_name_) + : function_name(function_name_), service_name(service_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"service_stop_begin"}; diff --git a/repertory/librepertory/include/events/types/service_stop_end.hpp b/repertory/librepertory/include/events/types/service_stop_end.hpp index ad4c3a89..6c12163a 100644 --- a/repertory/librepertory/include/events/types/service_stop_end.hpp +++ b/repertory/librepertory/include/events/types/service_stop_end.hpp @@ -28,9 +28,9 @@ namespace repertory { struct service_stop_end final : public i_event { service_stop_end() = default; - service_stop_end(std::string_view function_name_, std::string service_name_) - : function_name(std::string(function_name_)), - service_name(std::move(service_name_)) {} + service_stop_end(std::string_view function_name_, + std::string_view service_name_) + : function_name(function_name_), service_name(service_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"service_stop_end"}; diff --git a/repertory/librepertory/include/events/types/trace_log.hpp b/repertory/librepertory/include/events/types/trace_log.hpp index 7ad52be0..b1d79bb9 100644 --- a/repertory/librepertory/include/events/types/trace_log.hpp +++ b/repertory/librepertory/include/events/types/trace_log.hpp @@ -28,8 +28,8 @@ namespace repertory { struct trace_log final : public i_event { trace_log() = default; - trace_log(std::string_view function_name_, std::string msg_) - : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + trace_log(std::string_view function_name_, std::string_view msg_) + : function_name(function_name_), msg(msg_) {} static constexpr event_level level{event_level::trace}; static constexpr std::string_view name{"trace_log"}; diff --git a/repertory/librepertory/include/events/types/unmount_requested.hpp b/repertory/librepertory/include/events/types/unmount_requested.hpp index ab470889..a16db278 100644 --- a/repertory/librepertory/include/events/types/unmount_requested.hpp +++ b/repertory/librepertory/include/events/types/unmount_requested.hpp @@ -29,7 +29,7 @@ namespace repertory { struct unmount_requested final : public i_event { unmount_requested() = default; unmount_requested(std::string_view function_name_) - : function_name(std::string(function_name_)) {} + : function_name(function_name_) {} static constexpr event_level level{event_level::info}; static constexpr std::string_view name{"unmount_requested"}; diff --git a/repertory/librepertory/include/events/types/unmount_result.hpp b/repertory/librepertory/include/events/types/unmount_result.hpp index 1ae99aea..1ba18f38 100644 --- a/repertory/librepertory/include/events/types/unmount_result.hpp +++ b/repertory/librepertory/include/events/types/unmount_result.hpp @@ -29,10 +29,10 @@ namespace repertory { struct unmount_result final : public i_event { unmount_result() = default; - unmount_result(std::string_view function_name_, std::string mount_location_, - std::int32_t result_) - : function_name(std::string(function_name_)), - mount_location(std::move(mount_location_)), + unmount_result(std::string_view function_name_, + std::string_view mount_location_, std::int32_t result_) + : function_name(function_name_), + mount_location(mount_location_), result(result_) {} static constexpr event_level level{event_level::info}; diff --git a/repertory/librepertory/include/events/types/warn_log.hpp b/repertory/librepertory/include/events/types/warn_log.hpp index f75d48ad..ba127ba1 100644 --- a/repertory/librepertory/include/events/types/warn_log.hpp +++ b/repertory/librepertory/include/events/types/warn_log.hpp @@ -28,8 +28,8 @@ namespace repertory { struct warn_log final : public i_event { warn_log() = default; - warn_log(std::string_view function_name_, std::string msg_) - : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + warn_log(std::string_view function_name_, std::string_view msg_) + : function_name(function_name_), msg(msg_) {} static constexpr event_level level{event_level::warn}; static constexpr std::string_view name{"warn_log"}; diff --git a/repertory/librepertory/include/events/types/winfsp_event.hpp b/repertory/librepertory/include/events/types/winfsp_event.hpp index 21fb01df..7d0391bd 100644 --- a/repertory/librepertory/include/events/types/winfsp_event.hpp +++ b/repertory/librepertory/include/events/types/winfsp_event.hpp @@ -29,11 +29,9 @@ namespace repertory { struct winfsp_event final : public i_event { winfsp_event() = default; - winfsp_event(std::string api_path_, NTSTATUS error_, + winfsp_event(std::string_view api_path_, NTSTATUS error_, std::string_view function_name_) - : api_path(std::move(api_path_)), - error(error_), - function_name(std::string{function_name_}) {} + : api_path(api_path_), error(error_), function_name(function_name_) {} static constexpr event_level level{event_level::debug}; static constexpr std::string_view name{"winfsp_event"}; diff --git a/repertory/librepertory/include/file_manager/direct_open_file.hpp b/repertory/librepertory/include/file_manager/direct_open_file.hpp index ff0eebbd..ec63d49b 100644 --- a/repertory/librepertory/include/file_manager/direct_open_file.hpp +++ b/repertory/librepertory/include/file_manager/direct_open_file.hpp @@ -67,6 +67,8 @@ protected: -> api_error override; public: + void force_download() override {} + [[nodiscard]] auto get_source_path() const -> std::string override { return "direct"; } diff --git a/repertory/librepertory/include/file_manager/file_manager.hpp b/repertory/librepertory/include/file_manager/file_manager.hpp index 1c2b0f98..d48ad3d0 100644 --- a/repertory/librepertory/include/file_manager/file_manager.hpp +++ b/repertory/librepertory/include/file_manager/file_manager.hpp @@ -67,40 +67,41 @@ private: std::unordered_map> open_file_lookup_; stop_type stop_requested_{false}; + std::unordered_map> + unlinked_file_lookup_; std::unordered_map> upload_lookup_; mutable std::mutex upload_mtx_; std::condition_variable upload_notify_; std::unique_ptr upload_thread_; private: - [[nodiscard]] auto close_all(const std::string &api_path) -> bool; - void close_timed_out_files(); - [[nodiscard]] auto get_open_file_by_handle(std::uint64_t handle) const + [[nodiscard]] auto get_open_file_by_handle(std::uint64_t handle, + bool &is_unlinked) const -> std::shared_ptr; - [[nodiscard]] auto get_open_file_count(const std::string &api_path) const + [[nodiscard]] auto get_open_file_count(std::string_view api_path) const -> std::size_t; [[nodiscard]] auto get_stop_requested() const -> bool; - [[nodiscard]] auto open(const std::string &api_path, bool directory, + [[nodiscard]] auto open(std::string_view api_path, bool directory, const open_file_data &ofd, std::uint64_t &handle, std::shared_ptr &file, std::shared_ptr closeable_file) -> api_error; - void queue_upload(const std::string &api_path, const std::string &source_path, - bool no_lock); + void queue_upload(std::string_view api_path, std::string_view source_path, + bool is_unlinked, bool no_lock); - void remove_resume(const std::string &api_path, - const std::string &source_path, bool no_lock); + void remove_resume(std::string_view api_path, std::string_view source_path, + bool no_lock); - void remove_upload(const std::string &api_path, bool no_lock); + void remove_upload(std::string_view api_path, bool no_lock); - void swap_renamed_items(std::string from_api_path, std::string to_api_path, - bool directory); + void swap_renamed_items(std::string_view from_api_path, + std::string_view to_api_path, bool directory); void upload_completed(const file_upload_completed &evt); @@ -109,35 +110,45 @@ private: public: [[nodiscard]] auto get_next_handle() -> std::uint64_t; - auto handle_file_rename(const std::string &from_api_path, - const std::string &to_api_path) -> api_error; + auto handle_file_rename(std::string_view from_api_path, + std::string_view to_api_path) -> api_error; void queue_upload(const i_open_file &file) override; - void remove_resume(const std::string &api_path, - const std::string &source_path) override; + void remove_resume(std::string_view api_path, + std::string_view source_path) override; - static auto remove_source_and_shrink_cache(const std::string &api_path, - const std::string &source_path, + static auto remove_source_and_shrink_cache(std::string_view api_path, + std::string_view source_path, std::uint64_t file_size, bool allocated) -> bool; - void remove_upload(const std::string &api_path) override; + void remove_upload(std::string_view api_path) override; void store_resume(const i_open_file &file) override; public: void close(std::uint64_t handle); - [[nodiscard]] auto create(const std::string &api_path, api_meta_map &meta, + [[nodiscard]] auto create(std::string_view api_path, api_meta_map &meta, open_file_data ofd, std::uint64_t &handle, std::shared_ptr &file) -> api_error; - [[nodiscard]] auto evict_file(const std::string &api_path) -> bool override; + [[nodiscard]] auto download_pinned_file(std::string_view api_path) + -> bool override; - [[nodiscard]] auto get_directory_items(const std::string &api_path) const + [[nodiscard]] auto evict_file(std::string_view api_path) -> bool override; + + [[nodiscard]] auto get_directory_item(std::string_view api_path, + directory_item &item) const + -> api_error override; + + [[nodiscard]] auto get_directory_items(std::string_view api_path) const -> directory_item_list override; + [[nodiscard]] auto get_open_file(std::string_view api_path, + std::shared_ptr &file) -> bool; + [[nodiscard]] auto get_open_file(std::uint64_t handle, bool write_supported, std::shared_ptr &file) -> bool; @@ -153,7 +164,7 @@ public: [[nodiscard]] auto has_no_open_file_handles() const -> bool override; - [[nodiscard]] auto is_processing(const std::string &api_path) const + [[nodiscard]] auto is_processing(std::string_view api_path) const -> bool override; #if defined(PROJECT_TESTING) @@ -161,18 +172,20 @@ public: const open_file_data &ofd, std::uint64_t &handle, std::shared_ptr &file) -> api_error; #endif // defined(PROJECT_TESTING) - [[nodiscard]] auto open(const std::string &api_path, bool directory, + [[nodiscard]] auto open(std::string_view api_path, bool directory, const open_file_data &ofd, std::uint64_t &handle, std::shared_ptr &file) -> api_error; - [[nodiscard]] auto remove_file(const std::string &api_path) -> api_error; + [[nodiscard]] auto remove_directory(std::string_view api_path) -> api_error; - [[nodiscard]] auto rename_directory(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto remove_file(std::string_view api_path) -> api_error; + + [[nodiscard]] auto rename_directory(std::string_view from_api_path, + std::string_view to_api_path) -> api_error; - [[nodiscard]] auto rename_file(const std::string &from_api_path, - const std::string &to_api_path, bool overwrite) + [[nodiscard]] auto rename_file(std::string_view from_api_path, + std::string_view to_api_path, bool overwrite) -> api_error; void start(); diff --git a/repertory/librepertory/include/file_manager/i_file_manager.hpp b/repertory/librepertory/include/file_manager/i_file_manager.hpp index 2cab28cf..b3f5b9d2 100644 --- a/repertory/librepertory/include/file_manager/i_file_manager.hpp +++ b/repertory/librepertory/include/file_manager/i_file_manager.hpp @@ -31,11 +31,17 @@ class i_file_manager { INTERFACE_SETUP(i_file_manager); public: - [[nodiscard]] virtual auto evict_file(const std::string &api_path) + [[nodiscard]] virtual auto download_pinned_file(std::string_view api_path) -> bool = 0; + [[nodiscard]] virtual auto evict_file(std::string_view api_path) -> bool = 0; + + [[nodiscard]] virtual auto get_directory_item(std::string_view api_path, + directory_item &item) const + -> api_error = 0; + [[nodiscard]] virtual auto - get_directory_items(const std::string &api_path) const + get_directory_items(std::string_view api_path) const -> directory_item_list = 0; [[nodiscard]] virtual auto get_open_files() const @@ -43,7 +49,7 @@ public: [[nodiscard]] virtual auto has_no_open_file_handles() const -> bool = 0; - [[nodiscard]] virtual auto is_processing(const std::string &api_path) const + [[nodiscard]] virtual auto is_processing(std::string_view api_path) const -> bool = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/file_manager/i_open_file.hpp b/repertory/librepertory/include/file_manager/i_open_file.hpp index 55743e1e..cfdcd4d1 100644 --- a/repertory/librepertory/include/file_manager/i_open_file.hpp +++ b/repertory/librepertory/include/file_manager/i_open_file.hpp @@ -32,6 +32,8 @@ public: using native_operation_callback = std::function; public: + virtual void force_download() = 0; + [[nodiscard]] virtual auto get_api_path() const -> std::string = 0; [[nodiscard]] virtual auto get_chunk_size() const -> std::size_t = 0; @@ -62,13 +64,17 @@ public: [[nodiscard]] virtual auto get_source_path() const -> std::string = 0; + [[nodiscard]] virtual auto get_unlinked_meta() const -> api_meta_map = 0; + + [[nodiscard]] virtual auto has_handle(std::uint64_t handle) const -> bool = 0; + [[nodiscard]] virtual auto is_complete() const -> bool = 0; [[nodiscard]] virtual auto is_directory() const -> bool = 0; - [[nodiscard]] virtual auto is_write_supported() const -> bool = 0; + [[nodiscard]] virtual auto is_unlinked() const -> bool = 0; - [[nodiscard]] virtual auto has_handle(std::uint64_t handle) const -> bool = 0; + [[nodiscard]] virtual auto is_write_supported() const -> bool = 0; [[nodiscard]] virtual auto native_operation(native_operation_callback callback) -> api_error = 0; @@ -84,7 +90,7 @@ public: [[nodiscard]] virtual auto resize(std::uint64_t new_file_size) -> api_error = 0; - virtual void set_api_path(const std::string &api_path) = 0; + virtual void set_api_path(std::string_view api_path) = 0; [[nodiscard]] virtual auto write(std::uint64_t write_offset, const data_buffer &data, @@ -95,14 +101,14 @@ class i_closeable_open_file : public i_open_file { INTERFACE_SETUP(i_closeable_open_file); public: - virtual void add(std::uint64_t handle, open_file_data ofd) = 0; - - [[nodiscard]] virtual auto get_allocated() const -> bool = 0; + virtual void add(std::uint64_t handle, open_file_data ofd, bool notify) = 0; [[nodiscard]] virtual auto can_close() const -> bool = 0; virtual auto close() -> bool = 0; + [[nodiscard]] virtual auto get_allocated() const -> bool = 0; + [[nodiscard]] virtual auto get_handles() const -> std::vector = 0; @@ -111,6 +117,10 @@ public: virtual void remove(std::uint64_t handle) = 0; virtual void remove_all() = 0; + + virtual void set_unlinked(bool value) = 0; + + virtual void set_unlinked_meta(api_meta_map meta) = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/file_manager/i_upload_manager.hpp b/repertory/librepertory/include/file_manager/i_upload_manager.hpp index e66d77d6..309ea612 100644 --- a/repertory/librepertory/include/file_manager/i_upload_manager.hpp +++ b/repertory/librepertory/include/file_manager/i_upload_manager.hpp @@ -31,10 +31,10 @@ class i_upload_manager { public: virtual void queue_upload(const i_open_file &file) = 0; - virtual void remove_resume(const std::string &api_path, - const std::string &source_path) = 0; + virtual void remove_resume(std::string_view api_path, + std::string_view source_path) = 0; - virtual void remove_upload(const std::string &api_path) = 0; + virtual void remove_upload(std::string_view api_path) = 0; virtual void store_resume(const i_open_file &file) = 0; }; diff --git a/repertory/librepertory/include/file_manager/open_file.hpp b/repertory/librepertory/include/file_manager/open_file.hpp index eaf75c4b..9e2492c0 100644 --- a/repertory/librepertory/include/file_manager/open_file.hpp +++ b/repertory/librepertory/include/file_manager/open_file.hpp @@ -101,6 +101,8 @@ private: public: auto close() -> bool override; + void force_download() override; + [[nodiscard]] auto get_allocated() const -> bool override; [[nodiscard]] auto get_read_state() const -> boost::dynamic_bitset<> override; diff --git a/repertory/librepertory/include/file_manager/open_file_base.hpp b/repertory/librepertory/include/file_manager/open_file_base.hpp index ab527159..f306b04b 100644 --- a/repertory/librepertory/include/file_manager/open_file_base.hpp +++ b/repertory/librepertory/include/file_manager/open_file_base.hpp @@ -119,6 +119,8 @@ private: }; bool modified_{false}; bool removed_{false}; + bool unlinked_{false}; + api_meta_map unlinked_meta_; private: void file_io_thread(); @@ -164,7 +166,7 @@ protected: void wait_for_io(stop_type_callback stop_requested_cb); public: - void add(std::uint64_t handle, open_file_data ofd) override; + void add(std::uint64_t handle, open_file_data ofd, bool notify) override; [[nodiscard]] auto can_close() const -> bool override; @@ -202,19 +204,27 @@ public: [[nodiscard]] auto get_source_path() const -> std::string override; + [[nodiscard]] auto get_unlinked_meta() const -> api_meta_map override; + [[nodiscard]] auto has_handle(std::uint64_t handle) const -> bool override; [[nodiscard]] auto is_directory() const -> bool override { return fsi_.directory; } + [[nodiscard]] auto is_unlinked() const -> bool override; + [[nodiscard]] auto is_modified() const -> bool override; void remove(std::uint64_t handle) override; void remove_all() override; - void set_api_path(const std::string &api_path) override; + void set_api_path(std::string_view api_path) override; + + void set_unlinked(bool value) override; + + void set_unlinked_meta(api_meta_map meta) override; }; } // namespace repertory diff --git a/repertory/librepertory/include/file_manager/ring_buffer_base.hpp b/repertory/librepertory/include/file_manager/ring_buffer_base.hpp index 7da05a35..99daf491 100644 --- a/repertory/librepertory/include/file_manager/ring_buffer_base.hpp +++ b/repertory/librepertory/include/file_manager/ring_buffer_base.hpp @@ -57,8 +57,9 @@ private: private: std::condition_variable chunk_notify_; mutable std::mutex chunk_mtx_; + std::unique_ptr forward_reader_thread_; std::mutex read_mtx_; - std::unique_ptr reader_thread_; + std::unique_ptr reverse_reader_thread_; std::size_t ring_begin_{}; std::size_t ring_end_{}; std::size_t ring_pos_{}; @@ -69,7 +70,7 @@ private: auto download_chunk(std::size_t chunk, bool skip_active) -> api_error; - void reader_thread(); + void reader_thread(bool is_forward); void update_position(std::size_t count, bool is_forward); @@ -77,7 +78,7 @@ private: protected: [[nodiscard]] auto has_reader_thread() const -> bool { - return reader_thread_ != nullptr; + return forward_reader_thread_ != nullptr; } [[nodiscard]] auto get_ring_size() const -> std::size_t { @@ -139,7 +140,7 @@ public: void set(std::size_t first_chunk, std::size_t current_chunk); - void set_api_path(const std::string &api_path) override; + void set_api_path(std::string_view api_path) override; [[nodiscard]] auto write(std::uint64_t /* write_offset */, const data_buffer & /* data */, diff --git a/repertory/librepertory/include/file_manager/ring_buffer_open_file.hpp b/repertory/librepertory/include/file_manager/ring_buffer_open_file.hpp index 650e4562..1a5ceae5 100644 --- a/repertory/librepertory/include/file_manager/ring_buffer_open_file.hpp +++ b/repertory/librepertory/include/file_manager/ring_buffer_open_file.hpp @@ -43,8 +43,8 @@ public: ring_buffer_open_file() = delete; ring_buffer_open_file(const ring_buffer_open_file &) noexcept = delete; ring_buffer_open_file(ring_buffer_open_file &&) noexcept = delete; - auto operator=(ring_buffer_open_file &&) noexcept -> ring_buffer_open_file & = - delete; + auto operator=(ring_buffer_open_file &&) noexcept + -> ring_buffer_open_file & = delete; auto operator=(const ring_buffer_open_file &) noexcept -> ring_buffer_open_file & = delete; @@ -57,14 +57,14 @@ private: protected: [[nodiscard]] auto on_check_start() -> bool override; - [[nodiscard]] auto - on_chunk_downloaded(std::size_t chunk, - const data_buffer &buffer) -> api_error override; + [[nodiscard]] auto on_chunk_downloaded(std::size_t chunk, + const data_buffer &buffer) + -> api_error override; - [[nodiscard]] auto - on_read_chunk(std::size_t chunk, std::size_t read_size, - std::uint64_t read_offset, data_buffer &data, - std::size_t &bytes_read) -> api_error override; + [[nodiscard]] auto on_read_chunk(std::size_t chunk, std::size_t read_size, + std::uint64_t read_offset, data_buffer &data, + std::size_t &bytes_read) + -> api_error override; [[nodiscard]] auto use_buffer(std::size_t chunk, std::function func) @@ -75,8 +75,10 @@ public: std::size_t chunk_size, std::size_t ring_size) -> bool; - [[nodiscard]] auto - native_operation(native_operation_callback callback) -> api_error override; + void force_download() override {} + + [[nodiscard]] auto native_operation(native_operation_callback callback) + -> api_error override; [[nodiscard]] auto native_operation(std::uint64_t /* new_file_size */, native_operation_callback /* callback */) diff --git a/repertory/librepertory/include/platform/unix_platform.hpp b/repertory/librepertory/include/platform/unix_platform.hpp index fbb9ceab..418b132f 100644 --- a/repertory/librepertory/include/platform/unix_platform.hpp +++ b/repertory/librepertory/include/platform/unix_platform.hpp @@ -30,7 +30,8 @@ class i_provider; class lock_data final { public: - lock_data(provider_type prov, std::string_view unique_id); + lock_data(std::string_view data_directory, provider_type prov, + std::string_view unique_id); lock_data(const lock_data &) = delete; lock_data(lock_data &&) = delete; @@ -41,6 +42,7 @@ public: ~lock_data(); private: + std::string data_directory_; std::string mutex_id_; private: @@ -48,11 +50,11 @@ private: int lock_status_{EWOULDBLOCK}; private: - [[nodiscard]] static auto get_state_directory() -> std::string; - [[nodiscard]] auto get_lock_data_file() const -> std::string; - [[nodiscard]] auto get_lock_file() const -> std::string; + [[nodiscard]] auto get_lock_file(bool create_parent = true) const -> std::string; + + [[nodiscard]] auto get_state_directory() const -> std::string; private: [[nodiscard]] static auto wait_for_lock(int handle, @@ -71,13 +73,17 @@ public: -> bool; }; -[[nodiscard]] auto create_meta_attributes( - std::uint64_t accessed_date, std::uint32_t attributes, - std::uint64_t changed_date, std::uint64_t creation_date, bool directory, - std::uint32_t gid, const std::string &key, std::uint32_t mode, - std::uint64_t modified_date, std::uint32_t osx_backup, - std::uint32_t osx_flags, std::uint64_t size, const std::string &source_path, - std::uint32_t uid, std::uint64_t written_date) -> api_meta_map; +[[nodiscard]] auto +create_meta_attributes(std::uint64_t accessed_date, std::uint32_t attributes, + std::uint64_t changed_date, std::uint64_t creation_date, + bool directory, std::uint32_t gid, std::string_view key, + std::uint32_t mode, std::uint64_t modified_date, + std::uint32_t osx_flags, std::uint64_t size, + std::string_view source_path, std::uint32_t uid, + std::uint64_t written_date) -> api_meta_map; + +[[nodiscard]] auto provider_meta_creator(bool directory, const api_file &file) + -> api_meta_map; [[nodiscard]] auto provider_meta_handler(i_provider &provider, bool directory, const api_file &file) -> api_error; diff --git a/repertory/librepertory/include/platform/win32_platform.hpp b/repertory/librepertory/include/platform/win32_platform.hpp index 628a0d06..15022d69 100644 --- a/repertory/librepertory/include/platform/win32_platform.hpp +++ b/repertory/librepertory/include/platform/win32_platform.hpp @@ -30,7 +30,8 @@ class i_provider; class lock_data final { public: - explicit lock_data(provider_type prov, std::string unique_id); + explicit lock_data(std::string_view data_directory, provider_type prov, + std::string_view unique_id); lock_data(const lock_data &) = delete; lock_data(lock_data &&) = delete; @@ -40,6 +41,7 @@ public: auto operator=(lock_data &&) -> lock_data & = delete; private: + std::string dir_id_; std::string mutex_id_; HANDLE mutex_handle_{INVALID_HANDLE_VALUE}; DWORD mutex_state_{WAIT_FAILED}; @@ -58,13 +60,17 @@ public: std::int64_t pid) -> bool; }; -[[nodiscard]] auto create_meta_attributes( - std::uint64_t accessed_date, std::uint32_t attributes, - std::uint64_t changed_date, std::uint64_t creation_date, bool directory, - std::uint32_t gid, const std::string &key, std::uint32_t mode, - std::uint64_t modified_date, std::uint32_t osx_backup, - std::uint32_t osx_flags, std::uint64_t size, const std::string &source_path, - std::uint32_t uid, std::uint64_t written_date) -> api_meta_map; +[[nodiscard]] auto +create_meta_attributes(std::uint64_t accessed_date, std::uint32_t attributes, + std::uint64_t changed_date, std::uint64_t creation_date, + bool directory, std::uint32_t gid, std::string_view key, + std::uint32_t mode, std::uint64_t modified_date, + std::uint32_t osx_flags, std::uint64_t size, + std::string_view source_path, std::uint32_t uid, + std::uint64_t written_date) -> api_meta_map; + +[[nodiscard]] auto provider_meta_creator(bool directory, const api_file &file) + -> api_meta_map; [[nodiscard]] auto provider_meta_handler(i_provider &provider, bool directory, const api_file &file) -> api_error; diff --git a/repertory/librepertory/include/providers/base_provider.hpp b/repertory/librepertory/include/providers/base_provider.hpp index 292e4a58..6cd55e97 100644 --- a/repertory/librepertory/include/providers/base_provider.hpp +++ b/repertory/librepertory/include/providers/base_provider.hpp @@ -29,7 +29,7 @@ namespace repertory { class app_config; class i_file_manager; -class i_http_comm; +struct i_http_comm; class base_provider : public i_provider { private: @@ -49,8 +49,8 @@ private: private: api_item_added_callback api_item_added_; - std::unique_ptr db3_; - i_file_manager *fm_{}; + i_file_manager *fm_{nullptr}; + std::unique_ptr meta_db_; private: void add_all_items(stop_type &stop_requested); @@ -68,22 +68,21 @@ private: void remove_unmatched_source_files(stop_type &stop_requested); protected: - [[nodiscard]] static auto create_api_file(std::string path, std::string key, - std::uint64_t size, - std::uint64_t file_time) - -> api_file; + [[nodiscard]] static auto + create_api_file(std::string_view path, std::string_view key, + std::uint64_t size, std::uint64_t file_time) -> api_file; - [[nodiscard]] static auto create_api_file(std::string path, + [[nodiscard]] static auto create_api_file(std::string_view path, std::uint64_t size, api_meta_map &meta) -> api_file; - [[nodiscard]] virtual auto create_directory_impl(const std::string &api_path, + [[nodiscard]] virtual auto create_directory_impl(std::string_view api_path, api_meta_map &meta) -> api_error = 0; - [[nodiscard]] virtual auto - create_file_extra(const std::string & /* api_path */, - api_meta_map & /* meta */) -> api_error { + [[nodiscard]] virtual auto create_file_extra(std::string_view /* api_path */, + api_meta_map & /* meta */) + -> api_error { return api_error::success; } @@ -106,12 +105,12 @@ protected: return config_; } - [[nodiscard]] auto get_db() -> i_meta_db & { return *db3_; } + [[nodiscard]] auto get_db() -> i_meta_db & { return *meta_db_; } - [[nodiscard]] auto get_db() const -> const i_meta_db & { return *db3_; } + [[nodiscard]] auto get_db() const -> const i_meta_db & { return *meta_db_; } [[nodiscard]] virtual auto - get_directory_items_impl(const std::string &api_path, + get_directory_items_impl(std::string_view api_path, directory_item_list &list) const -> api_error = 0; [[nodiscard]] auto get_file_mgr() -> i_file_manager * { return fm_; } @@ -120,62 +119,61 @@ protected: return fm_; } - [[nodiscard]] virtual auto remove_directory_impl(const std::string &api_path) + [[nodiscard]] virtual auto remove_directory_impl(std::string_view api_path) -> api_error = 0; - [[nodiscard]] virtual auto remove_file_impl(const std::string &api_path) + [[nodiscard]] virtual auto remove_file_impl(std::string_view api_path) -> api_error = 0; - [[nodiscard]] virtual auto upload_file_impl(const std::string &api_path, - const std::string &source_path, + [[nodiscard]] virtual auto upload_file_impl(std::string_view api_path, + std::string_view source_path, stop_type &stop_requested) -> api_error = 0; public: [[nodiscard]] auto - create_directory_clone_source_meta(const std::string &source_api_path, - const std::string &api_path) + create_directory_clone_source_meta(std::string_view source_api_path, + std::string_view api_path) -> api_error override; - [[nodiscard]] auto create_directory(const std::string &api_path, + [[nodiscard]] auto create_directory(std::string_view api_path, api_meta_map &meta) -> api_error override; - [[nodiscard]] auto create_file(const std::string &api_path, - api_meta_map &meta) -> api_error override; + [[nodiscard]] auto create_file(std::string_view api_path, api_meta_map &meta) + -> api_error override; - [[nodiscard]] auto get_api_path_from_source(const std::string &source_path, + [[nodiscard]] auto get_api_path_from_source(std::string_view source_path, std::string &api_path) const -> api_error override; - [[nodiscard]] auto get_directory_items(const std::string &api_path, + [[nodiscard]] auto get_directory_item(std::string_view api_path, + directory_item &item) const + -> api_error override; + + [[nodiscard]] auto get_directory_items(std::string_view api_path, directory_item_list &list) const -> api_error override; - [[nodiscard]] auto get_file_size(const std::string &api_path, + [[nodiscard]] auto get_file_size(std::string_view api_path, std::uint64_t &file_size) const -> api_error override; - [[nodiscard]] auto get_filesystem_item(const std::string &api_path, + [[nodiscard]] auto get_filesystem_item(std::string_view api_path, bool directory, filesystem_item &fsi) const -> api_error override; - [[nodiscard]] auto get_filesystem_item_and_file(const std::string &api_path, - api_file &f, - filesystem_item &fsi) const - -> api_error override; - [[nodiscard]] auto - get_filesystem_item_from_source_path(const std::string &source_path, + get_filesystem_item_from_source_path(std::string_view source_path, filesystem_item &fsi) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, + [[nodiscard]] auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &key, + [[nodiscard]] auto get_item_meta(std::string_view api_path, + std::string_view key, std::string &value) const -> api_error override; @@ -186,28 +184,23 @@ public: [[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override; - [[nodiscard]] auto is_file_writeable(const std::string &api_path) const - -> bool override; - [[nodiscard]] auto is_read_only() const -> bool override { return false; } - [[nodiscard]] auto remove_directory(const std::string &api_path) + [[nodiscard]] auto remove_directory(std::string_view api_path) -> api_error override; - [[nodiscard]] auto remove_file(const std::string &api_path) + [[nodiscard]] auto remove_file(std::string_view api_path) -> api_error override; - [[nodiscard]] auto remove_item_meta(const std::string &api_path, - const std::string &key) + [[nodiscard]] auto remove_item_meta(std::string_view api_path, + std::string_view key) -> api_error override; - [[nodiscard]] auto set_item_meta(const std::string &api_path, - const std::string &key, - const std::string &value) + [[nodiscard]] auto set_item_meta(std::string_view api_path, + std::string_view key, std::string_view value) -> api_error override; - [[nodiscard]] auto set_item_meta(const std::string &api_path, - const api_meta_map &meta) + [[nodiscard]] auto set_item_meta(std::string_view api_path, api_meta_map meta) -> api_error override; [[nodiscard]] auto start(api_item_added_callback api_item_added, @@ -215,8 +208,8 @@ public: void stop() override; - [[nodiscard]] auto upload_file(const std::string &api_path, - const std::string &source_path, + [[nodiscard]] auto upload_file(std::string_view api_path, + std::string_view source_path, stop_type &stop_requested) -> api_error override; }; diff --git a/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp b/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp index d104aefb..2a861086 100644 --- a/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp +++ b/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp @@ -57,22 +57,25 @@ private: encrypt_config encrypt_config_; private: - std::unique_ptr db_{nullptr}; - i_file_manager *fm_{nullptr}; + std::unique_ptr file_db_{nullptr}; + utils::hash::hash_256_t master_key_{}; std::unordered_map> reader_lookup_; std::recursive_mutex reader_lookup_mtx_; private: - static auto create_api_file(const std::string &api_path, bool directory, - const std::string &source_path) -> api_file; + [[nodiscard]] static auto create_api_file(std::string_view api_path, + bool directory, + std::string_view source_path) + -> api_file; static void create_item_meta(api_meta_map &meta, bool directory, const api_file &file); - auto do_fs_operation(const std::string &api_path, bool directory, - std::function - callback) const -> api_error; + [[nodiscard]] auto do_fs_operation( + std::string_view api_path, bool directory, + std::function callback) const + -> api_error; [[nodiscard]] auto get_encrypt_config() const -> const encrypt_config & { return encrypt_config_; @@ -94,69 +97,67 @@ public: return true; } - [[nodiscard]] auto create_directory(const std::string &api_path, + [[nodiscard]] auto create_directory(std::string_view api_path, api_meta_map &meta) -> api_error override; [[nodiscard]] auto - create_directory_clone_source_meta(const std::string & /*source_api_path*/, - const std::string & /*api_path*/) + create_directory_clone_source_meta(std::string_view /*source_api_path*/, + std::string_view /*api_path*/) -> api_error override { return api_error::not_implemented; } - [[nodiscard]] auto create_file(const std::string & /*api_path*/, + [[nodiscard]] auto create_file(std::string_view /*api_path*/, api_meta_map & /*meta*/) -> api_error override { return api_error::not_implemented; } - [[nodiscard]] auto - get_api_path_from_source(const std::string & /*source_path*/, - std::string & /*api_path*/) const + [[nodiscard]] auto get_api_path_from_source(std::string_view /*source_path*/, + std::string & /*api_path*/) const -> api_error override; - [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const + [[nodiscard]] auto get_directory_item_count(std::string_view api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_directory_items(const std::string &api_path, + [[nodiscard]] auto get_directory_item(std::string_view api_path, + directory_item &item) const + -> api_error override; + + [[nodiscard]] auto get_directory_items(std::string_view api_path, directory_item_list &list) const -> api_error override; - [[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const + [[nodiscard]] auto get_file(std::string_view api_path, api_file &file) const -> api_error override; [[nodiscard]] auto get_file_list(api_file_list &list, std::string &marker) const -> api_error override; - [[nodiscard]] auto get_file_size(const std::string &api_path, + [[nodiscard]] auto get_file_size(std::string_view api_path, std::uint64_t &file_size) const -> api_error override; - [[nodiscard]] auto get_filesystem_item(const std::string &api_path, + [[nodiscard]] auto get_filesystem_item(std::string_view api_path, bool directory, filesystem_item &fsi) const -> api_error override; - [[nodiscard]] auto get_filesystem_item_and_file(const std::string &api_path, - api_file &file, - filesystem_item &fsi) const - -> api_error override; - [[nodiscard]] auto - get_filesystem_item_from_source_path(const std::string &source_path, + get_filesystem_item_from_source_path(std::string_view source_path, filesystem_item &fsi) const -> api_error override; [[nodiscard]] auto get_pinned_files() const -> std::vector override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, + [[nodiscard]] auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &key, + [[nodiscard]] auto get_item_meta(std::string_view api_path, + std::string_view key, std::string &value) const -> api_error override; @@ -170,14 +171,11 @@ public: [[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override; - [[nodiscard]] auto is_directory(const std::string &api_path, - bool &exists) const -> api_error override; - - [[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const + [[nodiscard]] auto is_directory(std::string_view api_path, bool &exists) const -> api_error override; - [[nodiscard]] auto is_file_writeable(const std::string &api_path) const - -> bool override; + [[nodiscard]] auto is_file(std::string_view api_path, bool &exists) const + -> api_error override; [[nodiscard]] auto is_online() const -> bool override; @@ -187,43 +185,41 @@ public: return false; } - [[nodiscard]] auto read_file_bytes(const std::string &api_path, + [[nodiscard]] auto read_file_bytes(std::string_view api_path, std::size_t size, std::uint64_t offset, data_buffer &data, stop_type &stop_requested) -> api_error override; - [[nodiscard]] auto remove_directory(const std::string & /*api_path*/) + [[nodiscard]] auto remove_directory(std::string_view /*api_path*/) -> api_error override { return api_error::not_implemented; } - [[nodiscard]] auto remove_file(const std::string & /*api_path*/) + [[nodiscard]] auto remove_file(std::string_view /*api_path*/) -> api_error override { return api_error::not_implemented; } - [[nodiscard]] auto remove_item_meta(const std::string & /*api_path*/, - const std::string & /*key*/) + [[nodiscard]] auto remove_item_meta(std::string_view api_path, + std::string_view key) + -> api_error override; + + [[nodiscard]] auto rename_file(std::string_view /*from_api_path*/, + std::string_view /*to_api_path*/) + -> api_error override { + return api_error::not_implemented; + } + + [[nodiscard]] auto set_item_meta(std::string_view /*api_path*/, + std::string_view /*key*/, + std::string_view /*value*/) -> api_error override { return api_error::success; } - [[nodiscard]] auto rename_file(const std::string & /*from_api_path*/, - const std::string & /*to_api_path*/) - -> api_error override { - return api_error::not_implemented; - } - - [[nodiscard]] auto set_item_meta(const std::string & /*api_path*/, - const std::string & /*key*/, - const std::string & /*value*/) - -> api_error override { - return api_error::success; - } - - [[nodiscard]] auto set_item_meta(const std::string & /*api_path*/, - const api_meta_map & /*meta*/) + [[nodiscard]] auto set_item_meta(std::string_view /*api_path*/, + api_meta_map /*meta*/) -> api_error override { return api_error::success; } @@ -233,8 +229,8 @@ public: void stop() override; - [[nodiscard]] auto upload_file(const std::string & /*api_path*/, - const std::string & /*source_path*/, + [[nodiscard]] auto upload_file(std::string_view /*api_path*/, + std::string_view /*source_path*/, stop_type & /*stop_requested*/) -> api_error override { return api_error::not_implemented; diff --git a/repertory/librepertory/include/providers/i_provider.hpp b/repertory/librepertory/include/providers/i_provider.hpp index d1b5f616..09cb0463 100644 --- a/repertory/librepertory/include/providers/i_provider.hpp +++ b/repertory/librepertory/include/providers/i_provider.hpp @@ -35,61 +35,61 @@ public: std::string &returned_version) const -> bool = 0; - [[nodiscard]] virtual auto create_directory(const std::string &api_path, + [[nodiscard]] virtual auto create_directory(std::string_view api_path, api_meta_map &meta) -> api_error = 0; [[nodiscard]] virtual auto - create_directory_clone_source_meta(const std::string &source_api_path, - const std::string &api_path) + create_directory_clone_source_meta(std::string_view source_api_path, + std::string_view api_path) -> api_error = 0; - [[nodiscard]] virtual auto create_file(const std::string &api_path, + [[nodiscard]] virtual auto create_file(std::string_view api_path, api_meta_map &meta) -> api_error = 0; [[nodiscard]] virtual auto - get_api_path_from_source(const std::string &source_path, + get_api_path_from_source(std::string_view source_path, std::string &api_path) const -> api_error = 0; [[nodiscard]] virtual auto - get_directory_item_count(const std::string &api_path) const + get_directory_item_count(std::string_view api_path) const -> std::uint64_t = 0; + [[nodiscard]] virtual auto get_directory_item(std::string_view api_path, + directory_item &list) const + -> api_error = 0; + [[nodiscard]] virtual auto - get_directory_items(const std::string &api_path, + get_directory_items(std::string_view api_path, directory_item_list &list) const -> api_error = 0; - [[nodiscard]] virtual auto get_file(const std::string &api_path, + [[nodiscard]] virtual auto get_file(std::string_view api_path, api_file &file) const -> api_error = 0; [[nodiscard]] virtual auto get_file_list(api_file_list &list, std::string &marker) const -> api_error = 0; - [[nodiscard]] virtual auto get_file_size(const std::string &api_path, + [[nodiscard]] virtual auto get_file_size(std::string_view api_path, std::uint64_t &file_size) const -> api_error = 0; - [[nodiscard]] virtual auto get_filesystem_item(const std::string &api_path, + [[nodiscard]] virtual auto get_filesystem_item(std::string_view api_path, bool directory, filesystem_item &fsi) const -> api_error = 0; [[nodiscard]] virtual auto - get_filesystem_item_and_file(const std::string &api_path, api_file &file, - filesystem_item &fsi) const -> api_error = 0; - - [[nodiscard]] virtual auto - get_filesystem_item_from_source_path(const std::string &source_path, + get_filesystem_item_from_source_path(std::string_view source_path, filesystem_item &fsi) const -> api_error = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, api_meta_map &meta) const -> api_error = 0; - [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, - const std::string &key, + [[nodiscard]] virtual auto get_item_meta(std::string_view api_path, + std::string_view key, std::string &value) const -> api_error = 0; @@ -104,15 +104,12 @@ public: [[nodiscard]] virtual auto get_used_drive_space() const -> std::uint64_t = 0; - [[nodiscard]] virtual auto is_directory(const std::string &api_path, + [[nodiscard]] virtual auto is_directory(std::string_view api_path, bool &exists) const -> api_error = 0; - [[nodiscard]] virtual auto is_file(const std::string &api_path, + [[nodiscard]] virtual auto is_file(std::string_view api_path, bool &exists) const -> api_error = 0; - [[nodiscard]] virtual auto - is_file_writeable(const std::string &api_path) const -> bool = 0; - [[nodiscard]] virtual auto is_online() const -> bool = 0; [[nodiscard]] virtual auto is_read_only() const -> bool = 0; @@ -120,40 +117,39 @@ public: [[nodiscard]] virtual auto is_rename_supported() const -> bool = 0; [[nodiscard]] virtual auto - read_file_bytes(const std::string &api_path, std::size_t size, + read_file_bytes(std::string_view api_path, std::size_t size, std::uint64_t offset, data_buffer &data, stop_type &stop_requested) -> api_error = 0; - [[nodiscard]] virtual auto remove_directory(const std::string &api_path) + [[nodiscard]] virtual auto remove_directory(std::string_view api_path) -> api_error = 0; - [[nodiscard]] virtual auto remove_file(const std::string &api_path) + [[nodiscard]] virtual auto remove_file(std::string_view api_path) -> api_error = 0; - [[nodiscard]] virtual auto remove_item_meta(const std::string &api_path, - const std::string &key) + [[nodiscard]] virtual auto remove_item_meta(std::string_view api_path, + std::string_view key) -> api_error = 0; - [[nodiscard]] virtual auto rename_file(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] virtual auto rename_file(std::string_view from_api_path, + std::string_view to_api_path) -> api_error = 0; - [[nodiscard]] virtual auto set_item_meta(const std::string &api_path, - const std::string &key, - const std::string &value) + [[nodiscard]] virtual auto set_item_meta(std::string_view api_path, + std::string_view key, + std::string_view value) -> api_error = 0; - [[nodiscard]] virtual auto set_item_meta(const std::string &api_path, - const api_meta_map &meta) - -> api_error = 0; + [[nodiscard]] virtual auto set_item_meta(std::string_view api_path, + api_meta_map meta) -> api_error = 0; [[nodiscard]] virtual auto start(api_item_added_callback api_item_added, i_file_manager *mgr) -> bool = 0; virtual void stop() = 0; - [[nodiscard]] virtual auto upload_file(const std::string &api_path, - const std::string &source_path, + [[nodiscard]] virtual auto upload_file(std::string_view api_path, + std::string_view source_path, stop_type &stop_requested) -> api_error = 0; }; diff --git a/repertory/librepertory/include/providers/provider.hpp b/repertory/librepertory/include/providers/provider.hpp index 0f6c1cab..28d92fdd 100644 --- a/repertory/librepertory/include/providers/provider.hpp +++ b/repertory/librepertory/include/providers/provider.hpp @@ -28,9 +28,8 @@ namespace repertory { class app_config; class i_provider; -[[nodiscard]] auto -create_provider(const provider_type &prov, - app_config &config) -> std::unique_ptr; +[[nodiscard]] auto create_provider(provider_type prov, app_config &config) + -> std::unique_ptr; } // namespace repertory #endif // REPERTORY_INCLUDE_PROVIDERS_PROVIDER_HPP_ diff --git a/repertory/librepertory/include/providers/s3/s3_provider.hpp b/repertory/librepertory/include/providers/s3/s3_provider.hpp index 22c5b518..7b49be16 100644 --- a/repertory/librepertory/include/providers/s3/s3_provider.hpp +++ b/repertory/librepertory/include/providers/s3/s3_provider.hpp @@ -24,14 +24,21 @@ #include "providers/base_provider.hpp" #include "types/repertory.hpp" +#include "utils/encryption.hpp" +#include "utils/hash.hpp" namespace repertory { class app_config; class i_file_manager; -class i_http_comm; +struct i_http_comm; struct head_object_result; class s3_provider final : public base_provider { +private: + using interate_callback_t = std::function; + public: static const constexpr auto type{provider_type::s3}; @@ -49,67 +56,83 @@ public: private: s3_config s3_config_; +private: + bool legacy_bucket_{true}; + utils::encryption::kdf_config master_kdf_cfg_{}; + utils::hash::hash_256_t master_key_{}; + private: [[nodiscard]] auto add_if_not_found(api_file &file, - const std::string &object_name) const + std::string_view object_name) const -> api_error; - [[nodiscard]] auto - create_directory_object(const std::string &api_path, - const std::string &object_name) const -> api_error; - - [[nodiscard]] auto create_directory_paths(const std::string &api_path, - const std::string &key) const + [[nodiscard]] auto create_directory_object(std::string_view api_path, + std::string_view object_name) const -> api_error; - [[nodiscard]] auto create_file_extra(const std::string &api_path, + [[nodiscard]] auto create_directory_paths(std::string_view api_path, + std::string_view key) const + -> api_error; + + [[nodiscard]] auto create_file_extra(std::string_view api_path, api_meta_map &meta) -> api_error override; [[nodiscard]] auto decrypt_object_name(std::string &object_name) const -> api_error; + [[nodiscard]] auto + get_kdf_config_from_meta(std::string_view api_path, + utils::encryption::kdf_config &cfg) const + -> api_error; + [[nodiscard]] auto get_last_modified(bool directory, - const std::string &api_path, + std::string_view api_path, std::uint64_t &last_modified) const -> api_error; [[nodiscard]] auto - get_object_info(bool directory, const std::string &api_path, - bool &is_encrypted, std::string &object_name, - head_object_result &result) const -> api_error; + get_object_info(bool directory, std::string_view api_path, bool &is_encrypted, + std::string &object_name, head_object_result &result) const + -> api_error; [[nodiscard]] auto get_object_list(std::string &response_data, long &response_code, - std::optional delimiter = std::nullopt, - std::optional prefix = std::nullopt, - std::optional token = std::nullopt) const + std::optional delimiter = std::nullopt, + std::optional prefix = std::nullopt, + std::optional token = std::nullopt) const -> bool; [[nodiscard]] auto get_s3_config() const -> const s3_config & { return s3_config_; } - [[nodiscard]] auto set_meta_key(const std::string &api_path, - api_meta_map &meta) -> api_error; + [[nodiscard]] auto initialize_crypto(const s3_config &cfg, bool is_retry) + -> bool; + + [[nodiscard]] auto + search_keys_for_master_kdf(std::string_view encryption_token) -> bool; + + [[nodiscard]] auto set_meta_key(std::string_view api_path, api_meta_map &meta) + -> api_error; protected: - [[nodiscard]] auto create_directory_impl(const std::string &api_path, + [[nodiscard]] auto create_directory_impl(std::string_view api_path, api_meta_map &meta) -> api_error override; - [[nodiscard]] auto get_directory_items_impl(const std::string &api_path, + [[nodiscard]] auto get_directory_items_impl(std::string_view api_path, directory_item_list &list) const -> api_error override; - [[nodiscard]] auto remove_directory_impl(const std::string &api_path) + [[nodiscard]] auto remove_directory_impl(std::string_view api_path) -> api_error override; - [[nodiscard]] auto remove_file_impl(const std::string &api_path) + [[nodiscard]] auto remove_file_impl(std::string_view api_path) -> api_error override; - [[nodiscard]] auto upload_file_impl(const std::string &api_path, - const std::string &source_path, + [[nodiscard]] auto upload_file_impl(std::string_view api_path, + std::string_view source_path, stop_type &stop_requested) -> api_error override; @@ -124,10 +147,10 @@ public: [[nodiscard]] static auto convert_api_date(std::string_view date) -> std::uint64_t; - [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const + [[nodiscard]] auto get_directory_item_count(std::string_view api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const + [[nodiscard]] auto get_file(std::string_view api_path, api_file &file) const -> api_error override; [[nodiscard]] auto get_file_list(api_file_list &list, @@ -140,10 +163,10 @@ public: return type; } - [[nodiscard]] auto is_directory(const std::string &api_path, - bool &exists) const -> api_error override; + [[nodiscard]] auto is_directory(std::string_view api_path, bool &exists) const + -> api_error override; - [[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const + [[nodiscard]] auto is_file(std::string_view api_path, bool &exists) const -> api_error override; [[nodiscard]] auto is_online() const -> bool override; @@ -152,18 +175,23 @@ public: return false; }; - [[nodiscard]] auto read_file_bytes(const std::string &api_path, + [[nodiscard]] auto iterate_prefix(std::string_view prefix, + interate_callback_t prefix_action, + interate_callback_t key_action) const + -> api_error; + + [[nodiscard]] auto read_file_bytes(std::string_view api_path, std::size_t size, std::uint64_t offset, data_buffer &data, stop_type &stop_requested) -> api_error override; - [[nodiscard]] auto rename_file(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto rename_file(std::string_view from_api_path, + std::string_view to_api_path) -> api_error override; - [[nodiscard]] auto start(api_item_added_callback api_item_added, - i_file_manager *mgr) -> bool override; + auto start(api_item_added_callback api_item_added, i_file_manager *mgr) + -> bool override; void stop() override; }; diff --git a/repertory/librepertory/include/providers/sia/sia_provider.hpp b/repertory/librepertory/include/providers/sia/sia_provider.hpp index e2897d29..bdc0e2de 100644 --- a/repertory/librepertory/include/providers/sia/sia_provider.hpp +++ b/repertory/librepertory/include/providers/sia/sia_provider.hpp @@ -28,7 +28,7 @@ namespace repertory { class app_config; class i_file_manager; -class i_http_comm; +struct i_http_comm; class sia_provider : public base_provider { public: @@ -49,17 +49,17 @@ private: sia_config sia_config_; private: - [[nodiscard]] auto create_directory_key(const std::string &api_path) const + [[nodiscard]] auto create_directory_key(std::string_view api_path) const -> repertory::api_error; - [[nodiscard]] auto ensure_directory_exists(const std::string &api_path) const + [[nodiscard]] auto ensure_directory_exists(std::string_view api_path) const -> api_error; - [[nodiscard]] auto get_object_info(const std::string &api_path, + [[nodiscard]] auto get_object_info(std::string_view api_path, json &object_info) const -> api_error; [[nodiscard]] auto - get_object_list(const std::string &api_path, nlohmann::json &object_list, + get_object_list(std::string_view api_path, nlohmann::json &object_list, std::optional marker = std::nullopt) const -> bool; @@ -68,26 +68,26 @@ private: } void iterate_objects( - const std::string &api_path, const json &object_list, - std::function handle_entry) const; + std::string_view api_path, const json &object_list, + std::function handle_entry) const; protected: - [[nodiscard]] auto create_directory_impl(const std::string &api_path, + [[nodiscard]] auto create_directory_impl(std::string_view api_path, api_meta_map &meta) -> api_error override; - [[nodiscard]] auto get_directory_items_impl(const std::string &api_path, + [[nodiscard]] auto get_directory_items_impl(std::string_view api_path, directory_item_list &list) const -> api_error override; - [[nodiscard]] auto remove_directory_impl(const std::string &api_path) + [[nodiscard]] auto remove_directory_impl(std::string_view api_path) -> api_error override; - [[nodiscard]] auto remove_file_impl(const std::string &api_path) + [[nodiscard]] auto remove_file_impl(std::string_view api_path) -> api_error override; - [[nodiscard]] auto upload_file_impl(const std::string &api_path, - const std::string &source_path, + [[nodiscard]] auto upload_file_impl(std::string_view api_path, + std::string_view source_path, stop_type &stop_requested) -> api_error override; @@ -96,10 +96,10 @@ public: std::string &returned_version) const -> bool override; - [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const + [[nodiscard]] auto get_directory_item_count(std::string_view api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const + [[nodiscard]] auto get_file(std::string_view api_path, api_file &file) const -> api_error override; [[nodiscard]] auto get_file_list(api_file_list &list, @@ -112,10 +112,10 @@ public: [[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override; - [[nodiscard]] auto is_directory(const std::string &api_path, - bool &exists) const -> api_error override; + [[nodiscard]] auto is_directory(std::string_view api_path, bool &exists) const + -> api_error override; - [[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const + [[nodiscard]] auto is_file(std::string_view api_path, bool &exists) const -> api_error override; [[nodiscard]] auto is_online() const -> bool override; @@ -124,14 +124,14 @@ public: return true; } - [[nodiscard]] auto read_file_bytes(const std::string &api_path, + [[nodiscard]] auto read_file_bytes(std::string_view api_path, std::size_t size, std::uint64_t offset, data_buffer &buffer, stop_type &stop_requested) -> api_error override; - [[nodiscard]] auto rename_file(const std::string &from_api_path, - const std::string &to_api_path) + [[nodiscard]] auto rename_file(std::string_view from_api_path, + std::string_view to_api_path) -> api_error override; [[nodiscard]] auto start(api_item_added_callback api_item_added, diff --git a/repertory/librepertory/include/rpc/client/client.hpp b/repertory/librepertory/include/rpc/client/client.hpp index 0e9f64de..baef3fa8 100644 --- a/repertory/librepertory/include/rpc/client/client.hpp +++ b/repertory/librepertory/include/rpc/client/client.hpp @@ -30,35 +30,40 @@ public: explicit client(rpc_host_info host_info); private: - const rpc_host_info host_info_; + rpc_host_info host_info_; std::atomic request_id_{0U}; public: - [[nodiscard]] auto get_drive_information() -> rpc_response; + [[nodiscard]] auto get_drive_information() const -> rpc_response; - [[nodiscard]] auto get_config() -> rpc_response; + [[nodiscard]] auto get_config() const -> rpc_response; - [[nodiscard]] auto get_config_value_by_name(const std::string &name) + [[nodiscard]] auto get_config_value_by_name(std::string_view name) const -> rpc_response; - [[nodiscard]] auto get_directory_items(const std::string &api_path) + [[nodiscard]] auto get_directory_items(std::string_view api_path) const -> rpc_response; - [[nodiscard]] auto get_open_files() -> rpc_response; - - [[nodiscard]] auto get_pinned_files() -> rpc_response; - - [[nodiscard]] auto pin_file(const std::string &api_path) -> rpc_response; - - [[nodiscard]] auto pinned_status(const std::string &api_path) -> rpc_response; - - [[nodiscard]] auto set_config_value_by_name(const std::string &name, - const std::string &value) + [[nodiscard]] auto get_item_info(std::string_view api_path) const -> rpc_response; - [[nodiscard]] auto unmount() -> rpc_response; + [[nodiscard]] auto get_open_files() const -> rpc_response; - [[nodiscard]] auto unpin_file(const std::string &api_path) -> rpc_response; + [[nodiscard]] auto get_pinned_files() const -> rpc_response; + + [[nodiscard]] auto pin_file(std::string_view api_path) const -> rpc_response; + + [[nodiscard]] auto pinned_status(std::string_view api_path) const + -> rpc_response; + + [[nodiscard]] auto set_config_value_by_name(std::string_view name, + std::string_view value) const + -> rpc_response; + + [[nodiscard]] auto unmount() const -> rpc_response; + + [[nodiscard]] auto unpin_file(std::string_view api_path) const + -> rpc_response; }; } // namespace repertory diff --git a/repertory/librepertory/include/rpc/common.hpp b/repertory/librepertory/include/rpc/common.hpp index fb2827a4..bb9a27fc 100644 --- a/repertory/librepertory/include/rpc/common.hpp +++ b/repertory/librepertory/include/rpc/common.hpp @@ -27,8 +27,12 @@ #include "utils/string.hpp" namespace repertory::rpc { -[[nodiscard]] auto check_authorization(const auto &cfg, - const httplib::Request &req) -> bool { +[[nodiscard]] auto create_password_hash(std::string_view password) + -> std::string; + +[[nodiscard]] inline auto check_authorization(const auto &cfg, + const httplib::Request &req) + -> bool { REPERTORY_USES_FUNCTION_NAME(); if (cfg.get_api_password().empty() || cfg.get_api_user().empty()) { @@ -61,16 +65,15 @@ namespace repertory::rpc { auto auth_str = std::string(data.begin(), data.end()); auto auth = utils::string::split(auth_str, ':', false); - if (auth.size() < 2U) { + if (auth.size() != 2U) { utils::error::raise_error(function_name, "authorization data is not valid"); return false; } auto user = auth.at(0U); - auth.erase(auth.begin()); - - auto pwd = utils::string::join(auth, ':'); - if ((user != cfg.get_api_user()) || (pwd != cfg.get_api_password())) { + auto pwd = auth.at(1U); + if ((user != cfg.get_api_user()) || + (pwd != create_password_hash(cfg.get_api_password()))) { utils::error::raise_error(function_name, "authorization failed"); return false; } diff --git a/repertory/librepertory/include/rpc/server/full_server.hpp b/repertory/librepertory/include/rpc/server/full_server.hpp index 99176efe..cbe935dc 100644 --- a/repertory/librepertory/include/rpc/server/full_server.hpp +++ b/repertory/librepertory/include/rpc/server/full_server.hpp @@ -43,6 +43,9 @@ private: void handle_get_directory_items(const httplib::Request &req, httplib::Response &res); + void handle_get_item_info(const httplib::Request &req, + httplib::Response &res); + void handle_get_drive_information(const httplib::Request &req, httplib::Response &res); diff --git a/repertory/librepertory/include/types/remote.hpp b/repertory/librepertory/include/types/remote.hpp index 0bc92b40..69bb5f6a 100644 --- a/repertory/librepertory/include/types/remote.hpp +++ b/repertory/librepertory/include/types/remote.hpp @@ -33,24 +33,27 @@ inline constexpr auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_WINFSP}; inline constexpr auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_FUSE}; #endif // defined(_WIN32) -inline constexpr auto default_remote_directory_page_size{std::size_t(100U)}; inline constexpr auto default_remote_client_pool_size{20U}; +inline constexpr auto default_remote_conn_timeout_ms{3000U}; +inline constexpr auto default_remote_directory_page_size{std::size_t(100U)}; inline constexpr auto default_remote_max_connections{20U}; -inline constexpr auto default_remote_receive_timeout_ms{120U * 1000U}; -inline constexpr auto default_remote_send_timeout_ms{30U * 1000U}; +inline constexpr auto default_remote_recv_timeout_ms{6000U}; +inline constexpr auto default_remote_send_timeout_ms{6000U}; namespace repertory::remote { struct remote_config final { std::uint16_t api_port{}; + std::uint32_t conn_timeout_ms{default_remote_conn_timeout_ms}; std::string encryption_token; std::string host_name_or_ip; std::uint8_t max_connections{default_remote_max_connections}; - std::uint32_t recv_timeout_ms{default_remote_receive_timeout_ms}; + std::uint32_t recv_timeout_ms{default_remote_recv_timeout_ms}; std::uint32_t send_timeout_ms{default_remote_send_timeout_ms}; auto operator==(const remote_config &cfg) const noexcept -> bool { if (&cfg != this) { return api_port == cfg.api_port && + conn_timeout_ms == cfg.conn_timeout_ms && encryption_token == cfg.encryption_token && host_name_or_ip == cfg.host_name_or_ip && max_connections == cfg.max_connections && @@ -228,6 +231,7 @@ template <> struct adl_serializer { static void to_json(json &data, const repertory::remote::remote_config &value) { data[repertory::JSON_API_PORT] = value.api_port; + data[repertory::JSON_CONNECT_TIMEOUT_MS] = value.conn_timeout_ms; data[repertory::JSON_ENCRYPTION_TOKEN] = value.encryption_token; data[repertory::JSON_HOST_NAME_OR_IP] = value.host_name_or_ip; data[repertory::JSON_MAX_CONNECTIONS] = value.max_connections; @@ -238,6 +242,9 @@ template <> struct adl_serializer { static void from_json(const json &data, repertory::remote::remote_config &value) { data.at(repertory::JSON_API_PORT).get_to(value.api_port); + if (data.contains(repertory::JSON_CONNECT_TIMEOUT_MS)) { + data.at(repertory::JSON_CONNECT_TIMEOUT_MS).get_to(value.conn_timeout_ms); + } data.at(repertory::JSON_ENCRYPTION_TOKEN).get_to(value.encryption_token); data.at(repertory::JSON_HOST_NAME_OR_IP).get_to(value.host_name_or_ip); data.at(repertory::JSON_MAX_CONNECTIONS).get_to(value.max_connections); diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 9e59cad3..96aa19dd 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -22,6 +22,9 @@ #ifndef REPERTORY_INCLUDE_TYPES_REPERTORY_HPP_ #define REPERTORY_INCLUDE_TYPES_REPERTORY_HPP_ +#include "utils/atomic.hpp" +#include "utils/encryption.hpp" + namespace repertory { inline constexpr auto default_api_password_size{48U}; inline constexpr auto default_download_timeout_secs{30U}; @@ -40,11 +43,13 @@ inline constexpr auto default_med_freq_interval_secs{ inline constexpr auto default_online_check_retry_secs{60U}; inline constexpr auto default_retry_read_count{6U}; inline constexpr auto default_ring_buffer_file_size{512U}; +inline constexpr auto default_rpc_port{std::uint16_t(10000U)}; inline constexpr auto default_task_wait_ms{100U}; inline constexpr auto default_timeout_ms{60000U}; inline constexpr auto default_ui_mgmt_port{std::uint16_t{30000U}}; inline constexpr auto max_ring_buffer_file_size{std::uint16_t(1024U)}; inline constexpr auto max_s3_object_name_length{1024U}; +inline constexpr auto max_s3_segment_name_length{255U}; inline constexpr auto min_cache_size_bytes{ std::uint64_t(100ULL * 1024ULL * 1024ULL), }; @@ -54,95 +59,6 @@ inline constexpr auto min_retry_read_count{std::uint16_t(2U)}; inline constexpr auto min_ring_buffer_file_size{std::uint16_t(64U)}; inline constexpr auto min_task_wait_ms{std::uint16_t(50U)}; -template class atomic final { -public: - atomic() : mtx_(std::make_shared()) {} - - atomic(const atomic &at_data) - : data_(at_data.load()), mtx_(std::make_shared()) {} - - atomic(data_t data) - : data_(std::move(data)), mtx_(std::make_shared()) {} - - atomic(atomic &&) = default; - - ~atomic() = default; - -private: - data_t data_; - std::shared_ptr mtx_; - -public: - [[nodiscard]] auto load() const -> data_t { - mutex_lock lock(*mtx_); - return data_; - } - - auto store(data_t data) -> data_t { - mutex_lock lock(*mtx_); - data_ = std::move(data); - return data_; - } - - auto operator=(const atomic &at_data) -> atomic & { - if (&at_data == this) { - return *this; - } - - store(at_data.load()); - return *this; - } - - auto operator=(atomic &&) -> atomic & = default; - - auto operator=(data_t data) -> atomic & { - if (&data == &data_) { - return *this; - } - - store(std::move(data)); - return *this; - } - - [[nodiscard]] auto operator==(const atomic &at_data) const -> bool { - if (&at_data == this) { - return true; - } - - mutex_lock lock(*mtx_); - return at_data.load() == data_; - } - - [[nodiscard]] auto operator==(const data_t &data) const -> bool { - if (&data == &data_) { - return true; - } - - mutex_lock lock(*mtx_); - return data == data_; - } - - [[nodiscard]] auto operator!=(const atomic &at_data) const -> bool { - if (&at_data == this) { - return false; - } - - mutex_lock lock(*mtx_); - return at_data.load() != data_; - } - - [[nodiscard]] auto operator!=(const data_t &data) const -> bool { - if (&data == &data_) { - return false; - } - - mutex_lock lock(*mtx_); - return data != data_; - } - - [[nodiscard]] operator data_t() const { return load(); } -}; - inline constexpr auto max_time{ std::numeric_limits::max(), }; @@ -154,6 +70,7 @@ inline constexpr std::string META_CHANGED{"changed"}; inline constexpr std::string META_CREATION{"creation"}; inline constexpr std::string META_DIRECTORY{"directory"}; inline constexpr std::string META_GID{"gid"}; +inline constexpr std::string META_KDF{"kdf"}; inline constexpr std::string META_KEY{"key"}; inline constexpr std::string META_MODE{"mode"}; inline constexpr std::string META_MODIFIED{"modified"}; @@ -164,11 +81,11 @@ inline constexpr std::string META_SOURCE{"source"}; inline constexpr std::string META_UID{"uid"}; inline constexpr std::string META_WRITTEN{"written"}; -inline constexpr std::array META_USED_NAMES = { - META_ACCESSED, META_ATTRIBUTES, META_BACKUP, META_CHANGED, - META_CREATION, META_DIRECTORY, META_GID, META_KEY, - META_MODE, META_MODIFIED, META_OSXFLAGS, META_PINNED, - META_SIZE, META_SOURCE, META_UID, META_WRITTEN, +inline constexpr std::array META_USED_NAMES = { + META_ACCESSED, META_ATTRIBUTES, META_BACKUP, META_CHANGED, META_CREATION, + META_DIRECTORY, META_GID, META_KDF, META_KEY, META_MODE, + META_MODIFIED, META_OSXFLAGS, META_PINNED, META_SIZE, META_SOURCE, + META_UID, META_WRITTEN, }; using api_meta_map = std::map; @@ -208,9 +125,11 @@ enum class api_error { no_disk_space, not_implemented, not_supported, + no_tty, os_error, out_of_memory, permission_denied, + stale_descriptor, upload_failed, xattr_buffer_small, xattr_exists, @@ -228,7 +147,7 @@ enum class database_type { sqlite, }; [[nodiscard]] auto -database_type_from_string(std::string type, +database_type_from_string(std::string_view type, database_type default_type = database_type::rocksdb) -> database_type; @@ -241,7 +160,7 @@ enum class download_type { ring_buffer, }; [[nodiscard]] auto -download_type_from_string(std::string type, +download_type_from_string(std::string_view type, download_type default_type = download_type::default_) -> download_type; @@ -258,7 +177,7 @@ enum class event_level { }; [[nodiscard]] auto -event_level_from_string(std::string level, +event_level_from_string(std::string_view type, event_level default_level = event_level::info) -> event_level; @@ -286,7 +205,10 @@ enum class exit_code : std::int32_t { init_failed = -18, ui_mount_failed = -19, exception = -20, - provider_offline = -21 + provider_offline = -21, + ui_failed = -22, + remove_failed = -23, + mount_not_found = -24, }; enum http_error_codes : std::int32_t { @@ -342,6 +264,7 @@ struct api_file final { std::string key; std::uint64_t modified_date{}; std::string source_path; + std::uint64_t written_date{}; }; struct directory_item final { @@ -354,11 +277,13 @@ struct directory_item final { struct encrypt_config final { std::string encryption_token; + utils::encryption::kdf_config kdf_cfg; std::string path; auto operator==(const encrypt_config &cfg) const noexcept -> bool { if (&cfg != this) { - return encryption_token == cfg.encryption_token && path == cfg.path; + return encryption_token == cfg.encryption_token && + kdf_cfg == cfg.kdf_cfg && path == cfg.path; } return true; @@ -416,6 +341,7 @@ struct s3_config final { std::string access_key; std::string bucket; std::string encryption_token; + bool force_legacy_encryption{false}; std::string region{"any"}; std::string secret_key; std::uint32_t timeout_ms{default_timeout_ms}; @@ -426,9 +352,11 @@ struct s3_config final { auto operator==(const s3_config &cfg) const noexcept -> bool { if (&cfg != this) { return access_key == cfg.access_key && bucket == cfg.bucket && - encryption_token == cfg.encryption_token && region == cfg.region && - secret_key == cfg.secret_key && timeout_ms == cfg.timeout_ms && - url == cfg.url && use_path_style == cfg.use_path_style && + encryption_token == cfg.encryption_token && + force_legacy_encryption == cfg.force_legacy_encryption && + region == cfg.region && secret_key == cfg.secret_key && + timeout_ms == cfg.timeout_ms && url == cfg.url && + use_path_style == cfg.use_path_style && use_region_in_url == cfg.use_region_in_url; } @@ -472,18 +400,21 @@ using meta_provider_callback = std::function; inline constexpr auto JSON_ACCESS_KEY{"AccessKey"}; inline constexpr auto JSON_AGENT_STRING{"AgentString"}; +inline constexpr auto JSON_ANIMATIONS{"Animations"}; inline constexpr auto JSON_API_PARENT{"ApiParent"}; inline constexpr auto JSON_API_PASSWORD{"ApiPassword"}; inline constexpr auto JSON_API_PATH{"ApiPath"}; inline constexpr auto JSON_API_PORT{"ApiPort"}; inline constexpr auto JSON_API_USER{"ApiUser"}; +inline constexpr auto JSON_AUTO_START{"AutoStart"}; inline constexpr auto JSON_BUCKET{"Bucket"}; inline constexpr auto JSON_CLIENT_POOL_SIZE{"ClientPoolSize"}; +inline constexpr auto JSON_CONNECT_TIMEOUT_MS{"ConnectTimeoutMs"}; inline constexpr auto JSON_DATABASE_TYPE{"DatabaseType"}; inline constexpr auto JSON_DIRECTORY{"Directory"}; inline constexpr auto JSON_DOWNLOAD_TIMEOUT_SECS{"DownloadTimeoutSeconds"}; -inline constexpr auto JSON_ENABLE_DRIVE_EVENTS{"EnableDriveEvents"}; inline constexpr auto JSON_ENABLE_DOWNLOAD_TIMEOUT{"EnableDownloadTimeout"}; +inline constexpr auto JSON_ENABLE_DRIVE_EVENTS{"EnableDriveEvents"}; inline constexpr auto JSON_ENABLE_MOUNT_MANAGER{"EnableMountManager"}; inline constexpr auto JSON_ENABLE_REMOTE_MOUNT{"Enable"}; inline constexpr auto JSON_ENCRYPTION_TOKEN{"EncryptionToken"}; @@ -491,15 +422,18 @@ inline constexpr auto JSON_ENCRYPT_CONFIG{"EncryptConfig"}; inline constexpr auto JSON_EVENT_LEVEL{"EventLevel"}; inline constexpr auto JSON_EVICTION_DELAY_MINS{"EvictionDelayMinutes"}; inline constexpr auto JSON_EVICTION_USE_ACCESS_TIME{"EvictionUseAccessedTime"}; +inline constexpr auto JSON_FORCE_LEGACY_ENCRYPTION{"ForceLegacyEncryption"}; inline constexpr auto JSON_HIGH_FREQ_INTERVAL_SECS{"HighFreqIntervalSeconds"}; inline constexpr auto JSON_HOST_CONFIG{"HostConfig"}; inline constexpr auto JSON_HOST_NAME_OR_IP{"HostNameOrIp"}; +inline constexpr auto JSON_KDF_CONFIG{"KDFConfig"}; inline constexpr auto JSON_LOW_FREQ_INTERVAL_SECS{"LowFreqIntervalSeconds"}; inline constexpr auto JSON_MAX_CACHE_SIZE_BYTES{"MaxCacheSizeBytes"}; inline constexpr auto JSON_MAX_CONNECTIONS{"MaxConnections"}; inline constexpr auto JSON_MAX_UPLOAD_COUNT{"MaxUploadCount"}; inline constexpr auto JSON_MED_FREQ_INTERVAL_SECS{"MedFreqIntervalSeconds"}; inline constexpr auto JSON_META{"Meta"}; +inline constexpr auto JSON_MOUNT_AUTO_START{"MountAutoStart"}; inline constexpr auto JSON_MOUNT_LOCATIONS{"MountLocations"}; inline constexpr auto JSON_ONLINE_CHECK_RETRY_SECS{"OnlineCheckRetrySeconds"}; inline constexpr auto JSON_PATH{"Path"}; @@ -546,12 +480,36 @@ template <> struct adl_serializer { template <> struct adl_serializer { static void to_json(json &data, const repertory::encrypt_config &value) { data[repertory::JSON_ENCRYPTION_TOKEN] = value.encryption_token; + data[repertory::JSON_KDF_CONFIG] = + repertory::utils::collection::to_hex_string(value.kdf_cfg.to_header()); data[repertory::JSON_PATH] = value.path; } static void from_json(const json &data, repertory::encrypt_config &value) { + REPERTORY_USES_FUNCTION_NAME(); data.at(repertory::JSON_ENCRYPTION_TOKEN).get_to(value.encryption_token); data.at(repertory::JSON_PATH).get_to(value.path); + + if (not data.contains(repertory::JSON_KDF_CONFIG)) { + return; + } + + auto kdf_str = data.at(repertory::JSON_KDF_CONFIG).get(); + if (kdf_str.empty()) { + return; + } + + repertory::data_buffer buffer; + if (not repertory::utils::collection::from_hex_string(kdf_str, buffer)) { + throw repertory::utils::error::create_exception( + function_name, {"failed to convert kdf config hex string to buffer"}); + } + + if (not repertory::utils::encryption::kdf_config::from_header( + buffer, value.kdf_cfg, true)) { + throw repertory::utils::error::create_exception( + function_name, {"failed to parse kdf header"}); + } } }; @@ -584,6 +542,8 @@ template <> struct adl_serializer { data[repertory::JSON_ACCESS_KEY] = value.access_key; data[repertory::JSON_BUCKET] = value.bucket; data[repertory::JSON_ENCRYPTION_TOKEN] = value.encryption_token; + data[repertory::JSON_FORCE_LEGACY_ENCRYPTION] = + value.force_legacy_encryption; data[repertory::JSON_REGION] = value.region; data[repertory::JSON_SECRET_KEY] = value.secret_key; data[repertory::JSON_TIMEOUT_MS] = value.timeout_ms; @@ -602,6 +562,10 @@ template <> struct adl_serializer { data.at(repertory::JSON_URL).get_to(value.url); data.at(repertory::JSON_USE_PATH_STYLE).get_to(value.use_path_style); data.at(repertory::JSON_USE_REGION_IN_URL).get_to(value.use_region_in_url); + if (data.contains(repertory::JSON_FORCE_LEGACY_ENCRYPTION)) { + data.at(repertory::JSON_FORCE_LEGACY_ENCRYPTION) + .get_to(value.force_legacy_encryption); + } } }; @@ -615,12 +579,15 @@ template <> struct adl_serializer { } }; -template struct adl_serializer> { - static void to_json(json &data, const repertory::atomic &value) { +template +struct adl_serializer> { + static void to_json(json &data, + const repertory::utils::atomic &value) { data = value.load(); } - static void from_json(const json &data, repertory::atomic &value) { + static void from_json(const json &data, + repertory::utils::atomic &value) { value.store(data.get()); } }; diff --git a/repertory/librepertory/include/types/rpc.hpp b/repertory/librepertory/include/types/rpc.hpp index c7a37663..c2da2537 100644 --- a/repertory/librepertory/include/types/rpc.hpp +++ b/repertory/librepertory/include/types/rpc.hpp @@ -30,13 +30,13 @@ struct rpc_host_info { std::string user; }; -enum class rpc_response_type { +enum class rpc_response_type : std::uint8_t { success, config_value_not_found, http_error, }; -struct rpc_response { +struct rpc_response final { rpc_response_type response_type; json data; }; @@ -45,6 +45,7 @@ namespace rpc_method { const std::string get_config = "get_config"; const std::string get_config_value_by_name = "get_config_value_by_name"; const std::string get_directory_items = "get_directory_items"; +const std::string get_item_info = "get_item_info"; const std::string get_drive_information = "get_drive_information"; const std::string get_open_files = "get_open_files"; const std::string get_pinned_files = "get_pinned_files"; diff --git a/repertory/librepertory/include/types/s3.hpp b/repertory/librepertory/include/types/s3.hpp index add306a1..f20954eb 100644 --- a/repertory/librepertory/include/types/s3.hpp +++ b/repertory/librepertory/include/types/s3.hpp @@ -31,16 +31,16 @@ namespace repertory { using get_key_callback = std::function; using get_api_file_token_callback = - std::function; + std::function; using get_name_callback = std::function; + std::string_view key, std::string_view object_name)>; using get_size_callback = std::function; using get_token_callback = std::function; -using set_key_callback = std::function; +using set_key_callback = std::function; using list_directories_result = api_file_list; diff --git a/repertory/librepertory/include/types/startup_exception.hpp b/repertory/librepertory/include/types/startup_exception.hpp index 22d672e0..12132a5d 100644 --- a/repertory/librepertory/include/types/startup_exception.hpp +++ b/repertory/librepertory/include/types/startup_exception.hpp @@ -25,8 +25,8 @@ namespace repertory { class startup_exception : public virtual std::runtime_error { public: - explicit startup_exception(const std::string &msg) - : std::runtime_error(msg) {} + explicit startup_exception(std::string_view msg) + : std::runtime_error(std::string{msg}) {} }; } // namespace repertory diff --git a/repertory/librepertory/include/utils/cli_utils.hpp b/repertory/librepertory/include/utils/cli_utils.hpp index bcbd5f9b..7029736c 100644 --- a/repertory/librepertory/include/utils/cli_utils.hpp +++ b/repertory/librepertory/include/utils/cli_utils.hpp @@ -39,14 +39,17 @@ inline const option generate_config_option = {"-gc", "--generate_config"}; inline const option get_option = {"-get", "--get"}; inline const option get_directory_items_option = {"-gdi", "--get_directory_items"}; +inline const option get_item_info_option = {"-gi", "--get_item_info"}; inline const option get_pinned_files_option = {"-gpf", "--get_pinned_files"}; inline const option help_option = {"-h", "--help"}; inline const option hidden_option = {"-hidden", "--hidden"}; +inline const option launch_only_option = {"-lo", "--launch_only"}; inline const option open_files_option = {"-of", "--open_files"}; inline const option pin_file_option = {"-pf", "--pin_file"}; inline const option pinned_status_option = {"-ps", "--pinned_status"}; inline const option password_option = {"-pw", "--password"}; inline const option remote_mount_option = {"-rm", "--remote_mount"}; +inline const option remove_option = {"-rp", "--remove"}; inline const option set_option = {"-set", "--set"}; inline const option status_option = {"-status", "--status"}; inline const option test_option = {"-test", "--test"}; @@ -68,14 +71,17 @@ inline const std::vector