4 Commits

Author SHA1 Message Date
62555e6125 v2.0.5-rc (#41)
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
Reviewed-on: #41
2025-03-26 07:02:38 -05:00
24418ba03d v2.0.4-rc (#37)
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
# Changelog

## v2.0.4-rc

### BREAKING CHANGES

* `renterd` v2.0.0+ is now required. Prior versions will fail to mount.

### Issues

* \#35 [bug] Low frequency check is set to '0' instead of 1 hour by default
* \#36 [bug] Max cache size bytes is set to '0' by default

### Changes from v2.0.3-rc

* Added Sia API version check prior to mounting
* Added back `-cv` (check version) CLI option
* Continue documentation updates
* Fixed setting `ApiAuth` via `set_value_by_name`
* Fixed setting `HostConfig.ApiUser` via `set_value_by_name`
* Fixed setting `HostConfig.Path` via `set_value_by_name`
* Fixed setting `HostConfig.Protocol` via `set_value_by_name`
* Improved ring buffer read-ahead
* Integrated `renterd` version 2.0.0
* Prefer using local cache file when opening files
* Refactored `app_config` unit tests
* Refactored polling to be more accurate on scheduling tasks

Reviewed-on: #37
2025-02-22 09:48:00 -06:00
fa439c634f v2.0.3-rc (#32)
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
# Changelog

## v2.0.3-rc

### Issues

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

### Changes from v2.0.2-rc

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

Reviewed-on: #32
2025-02-11 17:26:24 -06:00
8dd46b8ad8 v2.0.2-rc (#27)
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
## v2.0.2-rc

### BREAKING CHANGES

* Refactored `config.json` - will need to verify configuration settings prior to mounting

### Issues

* \#12 \[Unit Test\] Complete all providers unit tests
* \#14 \[Unit Test\] SQLite mini-ORM unit tests and cleanup
* \#16 Add support for bucket name in Sia provider
* \#17 Update to common c++ build system
  * A single 64-bit Linux Jenkins server is used to build all Linux and Windows versions
  * All dependency sources are now included
  * MSVC is no longer supported
  * MSYS2 is required for building Windows binaries on Windows
  * OS X support is temporarily disabled
* \#19 \[bug\] Rename file is broken for files that are existing
* \#23 \[bug\] Incorrect file size displayed while upload is pending
* \#24 RocksDB implementations should be transactional
* \#25 Writes should block when maximum cache size is reached
* \#26 Complete ring buffer and direct download support

### Changes from v2.0.1-rc

* Ability to choose between RocksDB and SQLite databases
* Added direct reads and implemented download fallback
* Corrected file times on S3 and Sia providers
* Corrected handling of `chown()` and `chmod()`
* Fixed erroneous download of chunks after resize

Reviewed-on: #27
2024-12-28 15:56:40 -06:00
503 changed files with 44315 additions and 23010 deletions

View File

@ -3,6 +3,7 @@ _mkgmtime
_sh_denyno
_sh_denyrd
_sh_denyrw
_spawnv
aarch64
advapi32
armv8
@ -23,13 +24,16 @@ cppflags
cpphttplib
cpptrace
cppvsdbg
create_notraverse
crypto_aead_xchacha20poly1305_ietf_npubbytes
cstdint
curlopt_aws_sigv4
cxxflags
cxxstd
d_largefile64_source
d_largefile_source
d_ndebug
dacl_security_information
dbackward_shared
dbghelp
dboost_root
@ -94,6 +98,7 @@ expect_streq
fallocate_impl
fext
fgetattr
fgetattr_impl
filebase
flac_version
flag_nopath
@ -110,6 +115,7 @@ googletest
gpath
gtest_version
has_setxattr
hkey
httpapi
httplib
icudata
@ -117,12 +123,15 @@ icui18n
icuuc
iostreams
iphlpapi
ipstream
jthread
libbitcoin
libbitcoinsystem
libcurl
libdsm
libevent
libexample
libexpat
libfuse3
libgmock
libgtest
@ -135,8 +144,13 @@ libuuid
libuuid_include_dirs
libvlc
linkflags
localappdata
lpbyte
lptr
lpwstr
markdownlint
mbig
minio
msvc
msvcr120
msys2
@ -144,16 +158,22 @@ mtune
musl-libc
nana
ncrypt
nlohmann
nlohmann_json
nmakeprg
nohup
nominmax
ntstatus
nullptr
nuspell_version
oleaut32
openal_version
openssldir
pistream
pkgconfig
plarge_integer
plex
println
project_enable_fontconfig
project_enable_gtkmm
project_enable_libdsm
@ -165,16 +185,21 @@ pugixml_project
puint32
pvoid
pwstr
rdrw
remote_winfsp
renterd
richtext
rocksdb_library
rpcrt4
s_igid
s_isvtx
s_iuid
sddl_revision_1
secp256k1
secur32
sfml_project
shlwapi
skynet
source_subdir
spdlog
spdlog_project
@ -186,6 +211,7 @@ stduuid_project
strequal
ularge_integer
uring
url
userenv
utimens_impl
utimensat

4
.gitattributes vendored Normal file
View File

@ -0,0 +1,4 @@
*.tgz 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
*.zip filter=lfs diff=lfs merge=lfs -text

View File

@ -6,7 +6,7 @@ pipeline {
environment {
DEVELOPER_PRIVATE_KEY = "/.ci/repertory/cert/developer.priv"
DEVELOPER_PUBLIC_KEY = "/.ci/repertory/cert/developer.pub"
PROJECT_TEST_DIR = "/.ci/repertory/test"
PROJECT_TEST_CONFIG_DIR = "/.ci/repertory/test_config"
}
options {

View File

@ -18,14 +18,14 @@ if vim.env.NV_DARCULA_ENABLE_DAP then
local externalConsole = gos.is_windows
local type = "cppdbg"
local cwd = gpath.create_path("./build")
local cwd = gpath.create_path("./dist/debug/shared/linux/x86_64/repertory/")
dap.configurations.cpp = {
{
name = "Mount",
type = type,
request = "launch",
program = function()
return gpath.create_path(cwd, "repertory")
return gpath.create_path(cwd, "bin/repertory")
end,
cwd = cwd,
stopAtEntry = true,
@ -36,8 +36,9 @@ if vim.env.NV_DARCULA_ENABLE_DAP then
type = type,
request = "launch",
program = function()
return gpath.create_path(cwd, "repertory_tests")
return gpath.create_path(cwd, "bin/repertory_test")
end,
args={"--gtest_filter=utils_db*"},
cwd = cwd,
stopAtEntry = true,
externalConsole=externalConsole,

View File

@ -1,23 +1,102 @@
# Changelog
## v2.0.2-rc
## v2.0.5-rc
### Issues
* \#12 \[Unit Test\] Complete all providers unit tests
* \#14 \[Unit Test \] SQLite mini-ORM unit tests and cleanup
* \#39 Create management portal in Flutter
### Changes from v2.0.4-rc
* Continue documentation updates
* Fixed `-status` command erasing active mount information
* Fixed overlapping HTTP REST API port's
* Refactored/fixed instance locking
* Removed passwords and secret key values from API calls
* Renamed setting `ApiAuth` to `ApiPassword`
* Require `--name,-na` option for encryption provider
## v2.0.4-rc
### BREAKING CHANGES
* `renterd` v2.0.0+ is now required. Prior versions will fail to mount.
<!-- markdownlint-disable-next-line -->
### Issues
* \#35 [bug] Low frequency check is set to '0' instead of 1 hour by default
* \#36 [bug] Max cache size bytes is set to '0' by default
### Changes from v2.0.3-rc
* Added Sia API version check prior to mounting
* Added back `-cv` (check version) CLI option
* Continue documentation updates
* Fixed setting `ApiAuth` via `set_value_by_name`
* Fixed setting `HostConfig.ApiUser` via `set_value_by_name`
* Fixed setting `HostConfig.Path` via `set_value_by_name`
* Fixed setting `HostConfig.Protocol` via `set_value_by_name`
* Improved ring buffer read-ahead
* Integrated `renterd` version 2.0.0
* Prefer using local cache file when opening files
* Refactored `app_config` unit tests
* Refactored polling to be more accurate on scheduling tasks
## v2.0.3-rc
<!-- markdownlint-disable-next-line -->
### Issues
* \#28 \[bug\] Address slow directory responses in S3 mounts for deeply nested directories
* \#29 \[bug\] S3 error responses are not being logged
* \#30 \[bug\] Sia provider error responses are not logged
* \#31 \[bug\] S3 provider should limit max key size to 1024
### Changes from v2.0.2-rc
* Always use direct for read-only providers
* Fixed externally removed files not being processed during cleanup
* Fixed http headers not being added for requests
* Fixed incorrect `stat` values for remote mounts
* Fixed invalid directory nullptr error on remote mounts
* Fixed memory leak in event system
* Refactored application shutdown
* Refactored event system
* Updated build system to Alpine 3.21.0
* Updated build system to MinGW-w64 12.0.0
* Updated copyright to 2018-2025
## v2.0.2-rc
### BREAKING CHANGES
* Refactored `config.json` - will need to verify configuration settings prior to mounting
<!-- markdownlint-disable-next-line -->
### Issues
* \#14 \[Unit Test\] SQLite mini-ORM unit tests and cleanup
* \#16 Add support for bucket name in Sia provider
* \#17 Update to common c++ build system
* A single 64-bit Linux Jenkins server is used to build all Linux and Windows versions
* All dependency sources are now included
* MSVC is no longer supported
* MSYS2 is required for building Windows binaries Windows
* MSYS2 is required for building Windows binaries on Windows
* OS X support is temporarily disabled
* \#19 \[bug\] Rename file is broken for files that are existing
* \#23 \[bug\] Incorrect file size displayed while upload is pending
* \#24 RocksDB implementations should be transactional
* \#25 Writes should block when maximum cache size is reached
* \#26 Complete ring buffer and direct download support
### Changes from v2.0.1-rc
* Ability to choose between RocksDB and SQLite databases
* Added direct reads and implemented download fallback
* Corrected file times on S3 and Sia providers
* Corrected handling of `chown()` and `chmod()`
* Fixed erroneous download of chunks after resize
## v2.0.1-rc

View File

@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 3.27)
cmake_policy(SET CMP0135 NEW)
cmake_policy(SET CMP0144 NEW)
if (NOT PROJECT_INTERFACE)
message(FATAL_ERROR "Project must be compiled via 'make_win32.cmd'/'make_win32.sh' or 'make_unix.sh' build scripts. Invoking 'cmake' directly is not supported.")
endif()
project(${PROJECT_NAME}
DESCRIPTION ${PROJECT_DESC}
HOMEPAGE_URL ${PROJECT_URL}
@ -54,6 +58,10 @@ if(PROJECT_IS_MINGW)
endif()
endif()
if (PROJECT_ENABLE_V2_ERRORS)
add_definitions(-DPROJECT_ENABLE_V2_ERRORS)
endif()
include(cmake/settings.cmake)
include(cmake/flags.cmake)
@ -139,6 +147,7 @@ endif()
-DPROJECT_COPYRIGHT=${PROJECT_COPYRIGHT}
-DPROJECT_DESC=${PROJECT_DESC}
-DPROJECT_DIST_DIR=${PROJECT_DIST_DIR}
-DPROJECT_ENABLE_V2_ERRORS=${PROJECT_ENABLE_V2_ERRORS}
-DPROJECT_ENABLE_WIN32_LONG_PATH_NAMES=${PROJECT_ENABLE_WIN32_LONG_PATH_NAMES}
-DPROJECT_ENABLE_BOOST=${PROJECT_ENABLE_BOOST}
-DPROJECT_ENABLE_CPP_HTTPLIB=${PROJECT_ENABLE_CPP_HTTPLIB}
@ -148,6 +157,7 @@ endif()
-DPROJECT_ENABLE_LIBSODIUM=${PROJECT_ENABLE_LIBSODIUM}
-DPROJECT_ENABLE_OPENSSL=${PROJECT_ENABLE_OPENSSL}
-DPROJECT_ENABLE_PUGIXML=${PROJECT_ENABLE_PUGIXML}
-DPROJECT_ENABLE_ROCKSDB=${PROJECT_ENABLE_ROCKSDB}
-DPROJECT_ENABLE_SPDLOG=${PROJECT_ENABLE_SPDLOG}
-DPROJECT_ENABLE_SQLITE=${PROJECT_ENABLE_SQLITE}
-DPROJECT_ENABLE_STDUUID=${PROJECT_ENABLE_STDUUID}
@ -157,6 +167,7 @@ endif()
-DPROJECT_FUSE=${PROJECT_FUSE}
-DPROJECT_FUSE_INCLUDE_DIRS=${PROJECT_FUSE_INCLUDE_DIRS}
-DPROJECT_GIT_REV=${PROJECT_GIT_REV}
-DPROJECT_INTERFACE=1
-DPROJECT_IS_ALPINE=${PROJECT_IS_ALPINE}
-DPROJECT_IS_ARM64=${PROJECT_IS_ARM64}
-DPROJECT_IS_MINGW=${PROJECT_IS_MINGW}

View File

@ -1,5 +1,5 @@
# Repertory MIT License
### Copyright <2018-2024> <scott.e.graves@protonmail.com>
### Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal 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:

446
README.md
View File

@ -1,68 +1,456 @@
# Repertory
Repertory allows you to mount AWS S3 and Sia via FUSE on Linux ~~/OS X~~ or via WinFSP
Repertory allows you to mount S3 and Sia via FUSE on Linux or via WinFSP
on Windows.
## Contents
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)
## Details and Features
* Optimized for [Plex Media Server](https://www.plex.tv/)
* Single application to mount AWS S3 and/or Sia
* Only 1 Sia mount and 1 S3 mount (per bucket) per user is supported.
* Remote mounting of Repertory instances on Linux ~~, OS X~~ and Windows
* Securely share your mounts over TCP/IP (`XChaCha20-Poly1305` stream cipher)
* Cross-platform support (Linux 64-bit, Linux arm64/aarch64, ~~OS X,~~ Windows 64-bit)
* 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
* [Sia renterd](https://github.com/SiaFoundation/renterd/releases) v0.4.0+ for Sia support
* Only 64-bit operating systems are supported
* By default, Linux requires `fusermount3`; otherwise, `repertory` must be manually compiled with `libfuse2` support
* ~~OS X requires the following dependency to be installed:~~
* ~~[FUSE for macOS v4.5.0](https://github.com/osxfuse/osxfuse/releases/download/macfuse-4.5.0/macfuse-4.5.0.dmg)~~
* Windows requires the following dependencies to be installed:
* [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 2023](https://github.com/winfsp/winfsp/releases/download/v2.0/winfsp-2.0.23075.msi)
## Supported Operating Systems
### Supported Operating Systems
Only 64-bit operating systems are supported
* Linux `arm64/aarch64`
* Linux `amd64`
* ~~OS X Mojave and above~~
* Windows 64-bit 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:
* `repertory -ui`
* The default username is `repertory`
* The default password is `repertory`
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.
### Screenshot
<a href="https://ibb.co/fVyJqnbF"><img src="https://i.ibb.co/fVyJqnbF/repertory-portal.png" alt="repertory-portal" border="0"></a>
## Usage
### Important Options
* `--help`
* Display all mount utility options
* `-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.
* `-dc`
* Display mount configuration
* For Sia, `--name` is optional
* For S3, the `-s3` option is required along with `--name`
### Sia
#### Sia Initial Configuration
* 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 '<my password>'`
* To specify a different bucket name while using `default` as the configuration name:
* `repertory -set HostConfig.ApiPassword '<my password>'`
* `repertory -set SiaConfig.Bucket '<my bucket>'`
* For all other configurations:
* `repertory --name '<my config name>' -set HostConfig.ApiPassword '<my password>'`
* `repertory --name '<my config name>' -set SiaConfig.Bucket '<my bucket name>'`
* Optional steps:
* Set a user name used during `renterd` basic authentication:
* `repertory -set HostConfig.ApiUser '<my user>'`
* `repertory --name '<my config name>' -set HostConfig.ApiUser '<my user>'`
* Set a custom agent string (default `Sia-Agent`):
* `repertory -set HostConfig.AgentString '<my agent>'`
* `repertory --name '<my config name>' -set HostConfig.AgentString '<my agent>'`
* Set the host name or IP of the `renterd` instance (default `localhost`):
* `repertory -set HostConfig.HostNameOrIp '<my host name>'`
* `repertory --name '<my config name>' -set HostConfig.HostNameOrIp '<my host name>'`
* Set the `renterd` API port (default `9980`):
* `repertory -set HostConfig.ApiPort 9981`
* `repertory --name '<my config name>' -set HostConfig.ApiPort 9981`
* To verify/view all configuration options:
* `repertory -dc`
* `repertory --name '<my config name>' -dc`
* Example:
* `repertory --name default -dc`
#### Sia Mounting
* Linux:
* `repertory /mnt/location`
* `repertory --name '<my config name>' /mnt/location`
* Example:
* `repertory --name default /mnt/location`
* Windows:
* `repertory t:`
* `repertory --name '<my config name>' t:`
* Example:
* `repertory --name default t:`
#### Sia Configuration File
```json
{
"ApiPassword": "<random generated rpc password>",
"ApiPort": 10000,
"ApiUser": "repertory",
"DatabaseType": "rocksdb",
"DownloadTimeoutSeconds": 30,
"EnableDownloadTimeout": true,
"EnableDriveEvents": false,
"EventLevel": "info",
"EvictionDelayMinutes": 1,
"EvictionUseAccessedTime": false,
"HighFreqIntervalSeconds": 30,
"HostConfig": {
"AgentString": "Sia-Agent",
"ApiPassword": "<renterd api password>",
"ApiPort": 9980,
"ApiUser": "",
"HostNameOrIp": "localhost",
"Path": "",
"Protocol": "http",
"TimeoutMs": 60000
},
"LowFreqIntervalSeconds": 3600,
"MaxCacheSizeBytes": 21474836480,
"MaxUploadCount": 5,
"MedFreqIntervalSeconds": 120,
"OnlineCheckRetrySeconds": 60,
"PreferredDownloadType": "default",
"RemoteMount": {
"ApiPort": 20000,
"ClientPoolSize": 20,
"Enable": false,
"EncryptionToken": ""
},
"RetryReadCount": 6,
"RingBufferFileSize": 512,
"SiaConfig": {
"Bucket": "default"
},
"TaskWaitMs": 100,
"Version": 1
}
```
### S3
#### S3 Initial Configuration
* Required steps:
* Set the appropriate base URL:
* `repertory -s3 --name '<my config name>' -set S3Config.URL '<my url>'`
* Example:
* `repertory -s3 --name minio -set S3Config.URL 'http://localhost:9000'`
* Set the appropriate bucket name:
* `repertory -s3 --name '<my config name>' -set S3Config.Bucket '<my bucket name>'`
* Set the appropriate access key:
* `repertory -s3 --name '<my config name>' -set S3Config.AccessKey '<my access key>'`
* Set the appropriate secret key:
* `repertory -s3 --name '<my config name>' -set S3Config.SecretKey '<my secret key>'`
* For Sia and most local S3 gateway instances, enable path style URL's:
* `repertory -s3 --name '<my config name>' -set S3Config.UsePathStyle true`
* Optional steps:
* Set an appropriate region. Default is set to `any`:
* `repertory -s3 --name '<my config name>' -set S3Config.Region '<my 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 '<my config name>' -set S3Config.EncryptionToken '<my strong password>'`
* To verify/view all configuration options:
* `repertory -s3 --name '<my config name>' -dc`
* Example:
* `repertory -s3 --name minio -dc`
#### S3 Mounting
* Linux:
* `repertory -s3 --name '<my config name>' /mnt/location`
* Example:
* `repertory -s3 --name minio /mnt/location`
* Windows:
* `repertory -s3 --name '<my config name>' t:`
* Example:
* `repertory -s3 --name minio t:`
#### S3 Configuration File
```json
{
"ApiPassword": "<random generated rpc password>",
"ApiPort": 10100,
"ApiUser": "repertory",
"DatabaseType": "rocksdb",
"DownloadTimeoutSeconds": 30,
"EnableDownloadTimeout": true,
"EnableDriveEvents": false,
"EventLevel": "info",
"EvictionDelayMinutes": 1,
"EvictionUseAccessedTime": false,
"HighFreqIntervalSeconds": 30,
"LowFreqIntervalSeconds": 3600,
"MaxCacheSizeBytes": 21474836480,
"MaxUploadCount": 5,
"MedFreqIntervalSeconds": 120,
"OnlineCheckRetrySeconds": 60,
"PreferredDownloadType": "default",
"RemoteMount": {
"ApiPort": 20100,
"ClientPoolSize": 20,
"Enable": false,
"EncryptionToken": ""
},
"RetryReadCount": 6,
"RingBufferFileSize": 512,
"S3Config": {
"AccessKey": "<my access key>",
"Bucket": "<my bucket name>",
"EncryptionToken": "",
"Region": "any",
"SecretKey": "<my secret key>",
"TimeoutMs": 60000,
"URL": "http://localhost:9000",
"UsePathStyle": true,
"UseRegionInURL": false
},
"TaskWaitMs": 100,
"Version": 1
}
```
### Data Directories
#### Linux Directories
* `~/.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.
### 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.
* Required steps:
* Enable remote mount:
* Sia
* `repertory -set RemoteMount.Enable true`
* `repertory --name '<my config name>' -set RemoteMount.Enable true`
* S3:
* `repertory -s3 --name '<my config name>' -set RemoteMount.Enable true`
* Set a secure encryption token:
* Sia:
* `repertory -set RemoteMount.EncryptionToken '<my secure password>'`
* `repertory --name '<my config name>' -set RemoteMount.EncryptionToken '<my secure password>'`
* S3:
* `repertory -s3 --name '<my config name>' -set RemoteMount.EncryptionToken '<my secure password>'`
* Optional steps:
* Change the port clients will use to connect to your mount:
* Sia:
* `repertory -set RemoteMount.ApiPort 20000`
* `repertory --name '<my config name>' -set RemoteMount.ApiPort 20000`
* S3:
* `repertory -s3 --name '<my config 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": "<my secure password>"
},
...
}
```
### Client Setup
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 <host name or IP>:<port> -set RemoteConfig.EncryptionToken '<my secure password>'`
* Replace `<host name or IP>` with the host name or IP of the server
* Replace `<port>` with the value of `RemoteMount.ApiPort` used in the server configuration
* Example:
* `repertory -rm 192.168.1.10:20000 -set RemoteConfig.EncryptionToken '<my secure password>'`
* `repertory -rm my.host.com:20000 -set RemoteConfig.EncryptionToken '<my secure password>'`
#### Client Remote Mounting
* Linux:
* `repertory -rm <host name or IP>:<port> /mnt/location`
* Example:
* `repertory -rm 192.168.1.10:20000 /mnt/location`
* Windows:
* `repertory -rm <host name or IP>:<port> t:`
* Example:
* `repertory -rm 192.168.1.10:20000 t:`
#### Remote Mount Configuration File
```json
{
"ApiPassword": "<random generated rpc password>",
"ApiPort": 10010,
"ApiUser": "repertory",
"EnableDriveEvents": false,
"EventLevel": "info",
"RemoteConfig": {
"ApiPort": 20000,
"EncryptionToken": "<my secure password>",
"HostNameOrIp": "192.168.1.10",
"MaxConnections": 20,
"ReceiveTimeoutMs": 120000,
"SendTimeoutMs": 30000
},
"TaskWaitMs": 100,
"Version": 1
}
```
## Compiling
* Successful compilation will result in all required files being placed in the `dist/` directory
* Linux
* Ensure `docker` is installed
Successful compilation will result in all files required for execution to be placed
in the `dist/` directory
### Linux Compilation
* Ensure `docker` is installed
* For x86_64:
* Release: `scripts/make_unix.sh x86_64`
* Debug: `scripts/make_unix.sh x86_64 debug`
* RelWithDebInfo: `scripts/make_unix.sh`
* Release: `scripts/make_unix.sh x86_64 Release`
* Debug: `scripts/make_unix.sh x86_64 Debug`
* For aarch64:
* Release: `scripts/make_unix.sh aarch64`
* Debug: `scripts/make_unix.sh aarch64 debug`
* Windows
* RECOMMENDED: Cross-compiling on Linux
* RelWithDebInfo: `scripts/make_unix.sh aarch64`
* Release: `scripts/make_unix.sh aarch64 Release`
* Debug: `scripts/make_unix.sh aarch64 Debug`
### Windows Compilation
* OFFICIAL: Cross-compiling on Linux
* Ensure `docker` is installed
* Release: `scripts/make_win32.sh`
* Debug: `scripts/make_win32.sh debug`
* Compiling on Windows
* RelWithDebInfo: `scripts/make_win32.sh`
* Release: `scripts/make_win32.sh x86_64 Release`
* Debug: `scripts/make_win32.sh x86_64 Debug`
* UNOFFICIAL: Compiling on Windows
* Ensure latest [MSYS2](https://www.msys2.org/) is installed
* Release: `scripts/make_win32.cmd`
* Debug: `scripts/make_win32.cmd debug`
* RelWithDebInfo: `scripts\make_win32.cmd`
* Release: `scripts\make_win32.cmd x86_64 Release`
* Debug: `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/)
* ~~[FUSE for macOS](https://osxfuse.github.io/)~~
* [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/)

View File

@ -1,41 +1,20 @@
set(BINUTILS_HASH ae9a5789e23459e59606e6714723f2d3ffc31c03174191ef0d015bdf06007450)
set(BINUTILS_HASH b53606f443ac8f01d1d5fc9c39497f2af322d99e14cea5c0b4b124d630379365)
set(BOOST2_HASH 7bd7ddceec1a1dfdcbdb3e609b60d01739c38390a5f956385a12f3122049f0ca)
set(BOOST_HASH be0d91732d5b0cc6fbb275c7939974457e79b54d6f07ce2e3dfdd68bef883b0b)
set(CLI11_HASH f2d893a65c3b1324c50d4e682c0cdc021dd0477ae2c048544f39eed6654b699a)
set(CPP_HTTPLIB_HASH c1742fc7179aaae2a67ad9bba0740b7e9ffaf4f5e62feef53101ecdef1478716)
set(CURL_HASH d714818f6ac41ae9154850158fed44b7a87650a6d52f83d3bcb9aa527be354d7)
set(CXXOPTS_HASH 841f49f2e045b9c6365997c2a8fbf76e6f215042dda4511a5bb04bc5ebc7f88a)
set(EXPAT_HASH fbd032683370d761ba68dba2566d3280a154f5290634172d60a79b24d366d9dc)
set(FLAC_HASH 0a4bb82a30609b606650d538a804a7b40205366ce8fc98871b0ecf3fbb0611ee)
set(FMT_HASH 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f)
set(FONTCONFIG_HASH f5f359d6332861bd497570848fcb42520964a9e83d5e3abe397b6b6db9bcaaf4)
set(FREETYPE2_HASH 5c3a8e78f7b24c20b25b54ee575d6daa40007a5f4eea2845861c3409b3021747)
set(BOOST_HASH f55c340aa49763b1925ccf02b2e83f35fdcf634c9d5164a2acb87540173c741d)
set(CPP_HTTPLIB_HASH c9b9e0524666e1cd088f0874c57c1ce7c0eaa8552f9f4e15c755d5201fc8c608)
set(CURL_HASH 6edc063d1ebaf9cf3b3b46e9fef2f3cd8932694989ecd43d005d6e828426d09f)
set(EXPAT_HASH 372b18f6527d162fa9658f1c74d22a37429b82d822f5a1e1fc7e00f6045a06a2)
set(GCC_HASH 7d376d445f93126dc545e2c0086d0f647c3094aae081cdb78f42ce2bc25e7293)
set(GTEST_HASH 7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926)
set(ICU_HASH 925e6b4b8cf8856e0ac214f6f34e30dee63b7bb7a50460ab4603950eff48f89e)
set(GTEST_HASH 78c676fc63881529bf97bf9d45948d905a66833fbfa5318ea2cd7478cb98f399)
set(ICU_HASH a2c443404f00098e9e90acf29dc318e049d2dc78d9ae5f46efb261934a730ce2)
set(JSON_HASH 0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406)
set(LIBDSM_HASH 747c4563d6291303d9b085c9e7dc96ac44f91871dcac3e20480fdcc066eee88a)
set(LIBEVENT_HASH 7180a979aaa7000e1264da484f712d403fcf7679b1e9212c4e3d09f5c93efc24)
set(LIBICONV_HASH 8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313)
set(LIBJPEG_TURBO_HASH a649205a90e39a548863a3614a9576a3fb4465f8e8e66d54999f127957c25b21)
set(LIBPNG_HASH fecc95b46cf05e8e3fc8a414750e0ba5aad00d89e9fdf175e94ff041caf1a03a)
set(LIBSODIUM_HASH 8e5aeca07a723a27bbecc3beef14b0068d37e7fc0e97f51b3f1c82d2a58005c1)
set(LIBTASN_HASH 1613f0ac1cf484d6ec0ce3b8c06d56263cc7242f1c23b30d82d23de345a63f7a)
set(MINGW_HASH 3f66bce069ee8bed7439a1a13da7cb91a5e67ea6170f21317ac7f5794625ee10)
set(NANA_HASH 56f7b1ed006c750fccf8ef15ab1e83f96751f2dfdcb68d93e5f712a6c9b58bcb)
set(NUSPELL_HASH 5d4baa1daf833a18dc06ae0af0571d9574cc849d47daff6b9ce11dac0a5ded6a)
set(OGG_HASH 0eb4b4b9420a0f51db142ba3f9c64b333f826532dc0f48c6410ae51f4799b664)
set(OPENAL_HASH dfddf3a1f61059853c625b7bb03de8433b455f2f79f89548cbcbd5edca3d4a4a)
set(OPENSSL_HASH 777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e)
set(MINGW_HASH cc41898aac4b6e8dd5cffd7331b9d9515b912df4420a3a612b5ea2955bbeed2f)
set(OPENSSL_HASH 002a2d6b30b58bf4bea46c43bdd96365aaf8daa6c428782aa4feee06da197df3)
set(PKG_CONFIG_HASH 6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591)
set(PUGIXML_HASH 2f10e276870c64b1db6809050a75e11a897a8d7456c4be5c6b2e35a11168a015)
set(ROCKSDB_HASH b20780586d3df4a3c5bcbde341a2c1946b03d18237960bda5bc5e9538f42af40)
set(SDL_HASH 254a767aa486fa6308d4473159c1f23c794610be775d63e98084111d96814b85)
set(SECP256K1_HASH 61583939f1f25b92e6401e5b819e399da02562de663873df3056993b40148701)
set(SFML_HASH 82535db9e57105d4f3a8aedabd138631defaedc593cab589c924b7d7a11ffb9d)
set(SPDLOG_HASH 1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b)
set(SQLITE_HASH 77823cb110929c2bcb0f5d48e4833b5c59a8a6e40cdea3936b99e199dbbe5784)
set(PUGIXML_HASH 655ade57fa703fb421c2eb9a0113b5064bddb145d415dd1f88c79353d90d511a)
set(ROCKSDB_HASH fdccab16133c9d927a183c2648bcea8d956fb41eb1df2aacaa73eb0b95e43724)
set(SPDLOG_HASH 25c843860f039a1600f232c6eb9e01e6627f7d030a2ae5e232bdd3c9205d26cc)
set(SQLITE_HASH 6cebd1d8403fc58c30e93939b246f3e6e58d0765a5cd50546f16c00fd805d2c3)
set(STDUUID_HASH b1176597e789531c38481acbbed2a6894ad419aab0979c10410d59eb0ebf40d3)
set(VORBIS_HASH 270c76933d0934e42c5ee0a54a36280e2d87af1de3cc3e584806357e237afd13)
set(WXWIDGETS_HASH 0ad86a3ad3e2e519b6a705248fc9226e3a09bbf069c6c692a02acf7c2d1c6b51)
set(ZLIB_HASH 17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c)

View File

@ -17,6 +17,7 @@ include(cmake/libraries/fuse.cmake)
include(cmake/libraries/json.cmake)
include(cmake/libraries/libsodium.cmake)
include(cmake/libraries/pugixml.cmake)
include(cmake/libraries/rocksdb.cmake)
include(cmake/libraries/spdlog.cmake)
include(cmake/libraries/sqlite.cmake)
include(cmake/libraries/stduuid.cmake)

View File

@ -120,11 +120,11 @@ 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
-j1
-j$ENV{CMAKE_BUILD_PARALLEL_LEVEL}
${BOOST_BUILD_ARGS}
INSTALL_COMMAND
./b2
-j1
-j$ENV{CMAKE_BUILD_PARALLEL_LEVEL}
${BOOST_BUILD_ARGS}
install
)

View File

@ -15,10 +15,13 @@ if(PROJECT_ENABLE_CPP_HTTPLIB)
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
-DBUILD_STATIC_LIBS=ON
-DHTTPLIB_REQUIRE_OPENSSL=${PROJECT_ENABLE_OPENSSL}
-DHTTPLIB_REQUIRE_ZLIB=ON
-DHTTPLIB_REQUIRE_BROTLI=OFF
-DHTTPLIB_REQUIRE_OPENSSL=ON
-DHTTPLIB_REQUIRE_ZLIB=ON
-DHTTPLIB_TEST=OFF
-DHTTPLIB_USE_BROTLI_IF_AVAILABLE=OFF
-DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=ON
-DHTTPLIB_USE_ZLIB_IF_AVAILABLE=ON
-DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS}
)

View File

@ -18,14 +18,18 @@ if(PROJECT_ENABLE_CURL)
URL ${PROJECT_3RD_PARTY_DIR}/curl-${CURL_VERSION}.tar.gz
URL_HASH SHA256=${CURL_HASH}
LIST_SEPARATOR |
CMAKE_ARGS
${PROJECT_EXTERNAL_CMAKE_FLAGS}
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
-DBUILD_STATIC_LIBS=ON
BUILD_COMMAND
${CMAKE_COMMAND} --build . -- -j$ENV{CMAKE_BUILD_PARALLEL_LEVEL}
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
-DBUILD_CURL_EXE=OFF
-DBUILD_LIBCURL_DOCS=OFF
-DBUILD_MISC_DOCS=OFF
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
-DBUILD_STATIC_CURL=ON
-DBUILD_STATIC_LIBS=ON
-DBUILD_STATIC_LIBS=ON
-DBUILD_TESTING=OFF
-DCURL_BROTLI=OFF
-DCURL_CA_BUNDLE=./cacert.pem
-DCURL_CA_FALLBACK=ON
-DCURL_DISABLE_LDAP=ON
@ -33,6 +37,7 @@ if(PROJECT_ENABLE_CURL)
-DCURL_USE_LIBSSH2=OFF
-DCURL_USE_OPENSSL=${PROJECT_ENABLE_OPENSSL}
-DCURL_ZLIB=ON
-DENABLE_CURL_MANUAL=OFF
-DENABLE_THREADED_RESOLVER=ON
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
-DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS}

View File

@ -0,0 +1,36 @@
if(PROJECT_ENABLE_ROCKSDB)
if(PROJECT_BUILD)
add_definitions(-DPROJECT_ENABLE_ROCKSDB)
find_library(ROCKSDB_LIBRARY NAMES librocksdb.a REQUIRED)
link_libraries(${ROCKSDB_LIBRARY})
elseif(NOT PROJECT_IS_MINGW OR CMAKE_HOST_WIN32)
ExternalProject_Add(rocksdb_project
PREFIX external
URL ${PROJECT_3RD_PARTY_DIR}/rocksdb-${ROCKSDB_VERSION}.tar.gz
URL_HASH SHA256=${ROCKSDB_HASH}
LIST_SEPARATOR |
BUILD_COMMAND
${CMAKE_COMMAND} --build . -- -j$ENV{CMAKE_BUILD_PARALLEL_LEVEL}
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_STATIC_LIBS=ON
-DFAIL_ON_WARNINGS=OFF
-DPORTABLE=1
-DROCKSDB_BUILD_SHARED=OFF
-DROCKSDB_INSTALL_ON_WINDOWS=ON
-DWITH_BENCHMARK=OFF
-DWITH_BENCHMARK_TOOLS=OFF
-DWITH_CORE_TOOLS=OFF
-DWITH_EXAMPLES=OFF
-DWITH_GFLAGS=OFF
-DWITH_IOSTATS_CONTEXT=OFF
-DWITH_PERF_CONTEXT=OFF
-DWITH_TESTS=OFF
-DWITH_TOOLS=OFF
-DWITH_TRACE_TOOLS=OFF
-DWITH_ZLIB=ON
)
list(APPEND PROJECT_DEPENDENCIES rocksdb_project)
endif()
endif()

View File

@ -2,7 +2,7 @@ if(PROJECT_ENABLE_SQLITE)
if(PROJECT_BUILD)
add_definitions(-DPROJECT_ENABLE_SQLITE)
if (PROJECT_IS_MINGW AND NOT PROJECT_IS_MINGW_UNIX)
pkg_check_modules(SQLITE3 REQUIRED sqlite3>=${SQLITE2_VERSION})
pkg_check_modules(SQLITE3 REQUIRED sqlite3)
include_directories(SYSTEM BEFORE ${SQLITE3_INCLUDE_DIRS})
link_libraries(${SQLITE3_LIBRARIES})
else()

View File

@ -6,6 +6,7 @@ option(PROJECT_ENABLE_JSON "Enable JSON for Modern C++ library" ON)
option(PROJECT_ENABLE_LIBSODIUM "Enable libsodium library" ON)
option(PROJECT_ENABLE_OPENSSL "Enable OpenSSL library" ON)
option(PROJECT_ENABLE_PUGIXML "Enable PugiXML library" ON)
option(PROJECT_ENABLE_ROCKSDB "Enable RocksDB library" ON)
option(PROJECT_ENABLE_SPDLOG "Enable spdlog library" ON)
option(PROJECT_ENABLE_SQLITE "Enable SQLite" ON)
option(PROJECT_ENABLE_STDUUID "Enable stduuid library" ON)

View File

@ -1,27 +1,28 @@
set(BINUTILS_VERSION 2.41)
set(BINUTILS_VERSION 2.43)
set(BOOST2_MAJOR_VERSION 1)
set(BOOST2_MINOR_VERSION 76)
set(BOOST2_PATCH_VERSION 0)
set(BOOST_MAJOR_VERSION 1)
set(BOOST_MINOR_VERSION 85)
set(BOOST_MINOR_VERSION 87)
set(BOOST_PATCH_VERSION 0)
set(CPP_HTTPLIB_VERSION 0.16.3)
set(CURL2_VERSION 8_9_1)
set(CURL_VERSION 8.9.1)
set(EXPAT2_VERSION 2_6_2)
set(EXPAT_VERSION 2.6.2)
set(CPP_HTTPLIB_VERSION 0.19.0)
set(CURL2_VERSION 8_12_1)
set(CURL_VERSION 8.12.1)
set(EXPAT2_VERSION 2_6_4)
set(EXPAT_VERSION 2.6.4)
set(GCC_VERSION 14.2.0)
set(GTEST_VERSION 1.15.2)
set(ICU_VERSION 75-1)
set(GTEST_VERSION 1.16.0)
set(ICU_VERSION 76-1)
set(JSON_VERSION 3.11.3)
set(LIBSODIUM_VERSION 1.0.20)
set(MESA_VERSION 23.3.3)
set(MINGW_VERSION 11.0.1)
set(OPENSSL_VERSION 3.3.1)
set(MINGW_VERSION 12.0.0)
set(OPENSSL_VERSION 3.4.1)
set(PKG_CONFIG_VERSION 0.29.2)
set(PUGIXML_VERSION 1.14)
set(SPDLOG_VERSION 1.14.1)
set(SQLITE2_VERSION 3.46.1)
set(SQLITE_VERSION 3460100)
set(PUGIXML_VERSION 1.15)
set(ROCKSDB_VERSION 9.10.0)
set(SPDLOG_VERSION 1.15.1)
set(SQLITE2_VERSION 3.49.1)
set(SQLITE_VERSION 3490100)
set(STDUUID_VERSION 1.2.3)
set(ZLIB_VERSION 1.3.1)

View File

@ -5,12 +5,12 @@ PROJECT_NAME="repertory"
PROJECT_COMPANY_NAME="https://git.fifthgrid.com/blockstorage"
PROJECT_URL="${PROJECT_COMPANY_NAME}/repertory"
PROJECT_COPYRIGHT="Copyright <2018-2024> <MIT License> <${PROJECT_URL}>"
PROJECT_COPYRIGHT="Copyright <2018-2025> <MIT License> <${PROJECT_URL}>"
PROJECT_DESC="Mount utility for Sia and S3"
PROJECT_MAJOR_VERSION=2
PROJECT_MINOR_VERSION=0
PROJECT_REVISION_VERSION=2
PROJECT_REVISION_VERSION=5
PROJECT_RELEASE_NUM=0
PROJECT_RELEASE_ITER=rc
@ -19,6 +19,8 @@ PROJECT_APP_LIST=(${PROJECT_NAME})
PROJECT_PRIVATE_KEY=${DEVELOPER_PRIVATE_KEY}
PROJECT_PUBLIC_KEY=${DEVELOPER_PUBLIC_KEY}
PROJECT_FLUTTER_BASE_HREF="/ui/"
PROJECT_ENABLE_WIN32_LONG_PATH_NAMES=OFF
PROJECT_ENABLE_BACKWARD_CPP=OFF
@ -30,6 +32,7 @@ PROJECT_ENABLE_JSON=ON
PROJECT_ENABLE_LIBSODIUM=ON
PROJECT_ENABLE_OPENSSL=ON
PROJECT_ENABLE_PUGIXML=ON
PROJECT_ENABLE_ROCKSDB=ON
PROJECT_ENABLE_SPDLOG=ON
PROJECT_ENABLE_SQLITE=ON
PROJECT_ENABLE_STDUUID=ON

View File

@ -1,4 +1,5 @@
FROM arm64v8/alpine:3.20.3
#comment
FROM arm64v8/alpine:3.21.3
MAINTAINER Scott E. Graves <scott.e.graves@protonmail.com>
CMD bash
@ -30,7 +31,7 @@ RUN apk add \
gflags \
gflags-dev \
git \
gtkmm3-dev \
git-lfs \
icu-dev \
icu-libs \
icu-static \
@ -69,7 +70,6 @@ RUN apk add \
tcl \
tcl-dev \
texinfo \
vlc-dev \
wget \
xz \
xz-dev \
@ -82,3 +82,6 @@ RUN apk add \
zstd-libs \
zstd-static \
xz-static
RUN ln -sf /usr/bin/aclocal-1.17 /usr/bin/aclocal-1.16
RUN ln -sf /usr/bin/automake-1.17 /usr/bin/automake-1.16

View File

@ -1,4 +1,5 @@
FROM alpine:3.20.3
#comment
FROM alpine:3.21.3
MAINTAINER Scott E. Graves <scott.e.graves@protonmail.com>
CMD bash
@ -30,6 +31,7 @@ RUN apk add \
gflags \
gflags-dev \
git \
git-lfs \
icu-dev \
icu-libs \
icu-static \
@ -80,3 +82,6 @@ RUN apk add \
zstd-libs \
zstd-static \
xz-static
RUN ln -sf /usr/bin/aclocal-1.17 /usr/bin/aclocal-1.16
RUN ln -sf /usr/bin/automake-1.17 /usr/bin/automake-1.16

48
docker/x86_64/flutter Normal file
View File

@ -0,0 +1,48 @@
FROM debian:latest
ARG UID=0
ARG GID=0
RUN apt-get update
RUN apt-get install -y \
bash \
curl \
fonts-droid-fallback \
gdb \
git \
lib32stdc++6 \
libgconf-2-4 \
libglu1-mesa \
libstdc++6 \
python3 \
unzip \
wget
RUN apt-get clean
RUN git clone https://github.com/flutter/flutter.git /flutter
RUN git config --system --add safe.directory /flutter
ENV PATH="/flutter/bin:/flutter/bin/cache/dart-sdk/bin:${PATH}"
RUN flutter doctor -v
RUN flutter channel master
RUN flutter upgrade
RUN flutter --disable-analytics
RUN flutter config --no-analytics
RUN flutter config --enable-web
RUN flutter config --no-cli-animations
RUN mkdir /nonexistent
RUN chown -R $UID:$GID /nonexistent
RUN mkdir /.config
RUN chown -R $UID:$GID /.config
RUN mkdir /.dart-tool
RUN chown -R $UID:$GID /.dart-tool
RUN mkdir /.pub-cache
RUN chown -R $UID:$GID /.pub-cache
RUN chown -R $UID:$GID /flutter

View File

@ -1,5 +1,5 @@
#comment
FROM alpine:3.20.3
FROM alpine:3.21.3
RUN apk update
RUN apk upgrade
@ -18,6 +18,7 @@ RUN apk add \
gcc \
gettext \
git \
git-lfs \
gmp \
gmp-dev \
gperf \
@ -572,8 +573,8 @@ RUN if [ -f "/3rd_party/flac-${MY_FLAC_VERSION}.tar.gz" ]; then \
&& cd build \
&& cmake .. \
-DBUILD_DOCS=OFF \
-DBUILD_EXAMPLES=ON \
-DBUILD_PROGRAMS=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_PROGRAMS=OFF \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_TESTING=OFF \
@ -604,6 +605,7 @@ RUN if [ -f "/3rd_party/SFML-${MY_SFML_VERSION}.tar.gz" ]; then \
-DBUILD_STATIC_LIBS=ON \
-DCMAKE_CXX_STANDARD=${MY_CXX_STANDARD} \
-DCMAKE_INSTALL_PREFIX=${MY_MINGW_DIR} \
-DCMAKE_SYSTEM_PROCESSOR=AMD64 \
-DCMAKE_TOOLCHAIN_FILE=${MY_TOOLCHAIN_FILE_CMAKE} \
&& make -j${MY_NUM_JOBS} \
&& make install \
@ -670,12 +672,15 @@ RUN if [ -f "/3rd_party/curl-${MY_CURL_VERSION}.tar.gz" ]; then \
&& cd build \
&& cmake .. \
-DBUILD_CURL_EXE=ON \
-DBUILD_LIBCURL_DOCS=OFF \
-DBUILD_MISC_DOCS=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_TESTING=OFF \
-DCMAKE_CXX_STANDARD=${MY_CXX_STANDARD} \
-DCMAKE_INSTALL_PREFIX=${MY_MINGW_DIR} \
-DCMAKE_TOOLCHAIN_FILE=${MY_TOOLCHAIN_FILE_CMAKE} \
-DCURL_BROTLI=OFF \
-DCURL_CA_BUNDLE=./cacert.pem \
-DCURL_CA_FALLBACK=ON \
-DCURL_DISABLE_LDAP=ON \
@ -683,6 +688,7 @@ RUN if [ -f "/3rd_party/curl-${MY_CURL_VERSION}.tar.gz" ]; then \
-DCURL_USE_LIBSSH2=OFF \
-DCURL_USE_OPENSSL=ON \
-DCURL_ZLIB=ON \
-DENABLE_CURL_MANUAL=OFF \
-DENABLE_THREADED_RESOLVER=ON \
-DOPENSSL_USE_STATIC_LIBS=ON \
-DUSE_LIBIDN2=OFF \
@ -710,6 +716,9 @@ RUN if [ -f "/3rd_party/cpp-httplib-${MY_CPP_HTTPLIB_VERSION}.tar.gz" ]; then \
-DHTTPLIB_REQUIRE_OPENSSL=ON \
-DHTTPLIB_REQUIRE_ZLIB=ON \
-DHTTPLIB_TEST=OFF \
-DHTTPLIB_USE_BROTLI_IF_AVAILABLE=OFF \
-DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=YES \
-DHTTPLIB_USE_ZLIB_IF_AVAILABLE=ON \
&& make -j${MY_NUM_JOBS} \
&& make install \
&& cd ${MY_WORKDIR} \

View File

@ -3,8 +3,8 @@
CURRENT_DIR=$(dirname "$0")
CURRENT_DIR=$(realpath ${CURRENT_DIR})
rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_config/ \
${PROJECT_BUILD_DIR}/build/test_config/
rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_input/ \
${PROJECT_BUILD_DIR}/build/test_input/
rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_config/ \
${PROJECT_DIST_DIR}/test_config/
rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_input/ \
${PROJECT_DIST_DIR}/test_input/

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,440 +19,246 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_APP_CONFIG_HPP_
#define INCLUDE_APP_CONFIG_HPP_
#ifndef REPERTORY_INCLUDE_APP_CONFIG_HPP_
#define REPERTORY_INCLUDE_APP_CONFIG_HPP_
#include "events/event_system.hpp"
#include "events/events.hpp"
#include "types/remote.hpp"
#include "types/repertory.hpp"
#include "utils/error_utils.hpp"
namespace repertory {
class app_config final {
private:
static stop_type stop_requested;
public:
[[nodiscard]] static auto
default_agent_name(const provider_type &prov) -> std::string;
[[nodiscard]] static auto default_agent_name(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto
default_api_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto default_api_port(const provider_type &prov)
-> std::uint16_t;
[[nodiscard]] static auto
default_data_directory(const provider_type &prov) -> std::string;
[[nodiscard]] static auto default_data_directory(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto
default_remote_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto default_remote_api_port(const provider_type &prov)
-> std::uint16_t;
[[nodiscard]] static auto
default_rpc_port(const 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) -> std::string;
[[nodiscard]] static auto get_provider_display_name(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto
get_provider_name(const provider_type &prov) -> std::string;
[[nodiscard]] static auto get_provider_name(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto get_root_data_directory() -> std::string;
public:
[[nodiscard]] static auto get_stop_requested() -> bool;
static void set_stop_requested();
public:
app_config(const provider_type &prov, std::string_view data_directory = "");
app_config() = delete;
app_config(app_config &&) = delete;
app_config(const app_config &) = delete;
~app_config() { save(); }
auto operator=(const app_config &) -> app_config & = delete;
auto operator=(app_config &&) -> app_config & = delete;
private:
provider_type prov_;
std::string api_auth_;
std::uint16_t api_port_;
std::string api_user_;
bool config_changed_;
std::string data_directory_;
std::uint8_t download_timeout_secs_;
bool enable_chunk_downloader_timeout_;
bool enable_comm_duration_events_;
bool enable_drive_events_;
bool enable_max_cache_size_;
atomic<std::string> api_password_;
std::atomic<std::uint16_t> api_port_;
atomic<std::string> api_user_;
std::atomic<bool> config_changed_;
std::atomic<database_type> db_type_{database_type::rocksdb};
std::atomic<std::uint8_t> download_timeout_secs_;
std::atomic<bool> enable_download_timeout_;
std::atomic<bool> enable_drive_events_;
#if defined(_WIN32)
bool enable_mount_manager_;
#endif
bool enable_remote_mount_;
encrypt_config encrypt_config_;
event_level event_level_;
std::uint32_t eviction_delay_mins_;
bool eviction_uses_accessed_time_;
std::uint8_t high_freq_interval_secs_;
bool is_remote_mount_;
std::uint32_t low_freq_interval_secs_;
std::uint64_t max_cache_size_bytes_;
std::uint8_t max_upload_count_;
std::uint8_t min_download_timeout_secs_;
std::uint16_t online_check_retry_secs_;
std::uint16_t orphaned_file_retention_days_;
std::string preferred_download_type_;
std::uint8_t read_ahead_count_;
std::uint8_t remote_client_pool_size_;
std::string remote_host_name_or_ip_;
std::uint8_t remote_max_connections_;
std::uint16_t remote_port_;
std::uint16_t remote_receive_timeout_secs_;
std::uint16_t remote_send_timeout_secs_;
std::string remote_token_;
std::uint16_t retry_read_count_;
std::uint16_t ring_buffer_file_size_;
std::atomic<bool> enable_mount_manager_;
#endif // defined(_WIN32)
std::atomic<event_level> event_level_;
std::atomic<std::uint32_t> eviction_delay_mins_;
std::atomic<bool> eviction_uses_accessed_time_;
std::atomic<std::uint16_t> high_freq_interval_secs_;
std::atomic<std::uint16_t> low_freq_interval_secs_;
std::atomic<std::uint64_t> max_cache_size_bytes_;
std::atomic<std::uint8_t> max_upload_count_;
std::atomic<std::uint16_t> med_freq_interval_secs_;
std::atomic<std::uint16_t> online_check_retry_secs_;
std::atomic<download_type> preferred_download_type_;
std::atomic<std::uint16_t> retry_read_count_;
std::atomic<std::uint16_t> ring_buffer_file_size_;
std::atomic<std::uint16_t> task_wait_ms_;
private:
std::string cache_directory_;
host_config hc_;
s3_config s3_config_;
sia_config sia_config_{"default"};
std::uint64_t version_{REPERTORY_CONFIG_VERSION};
std::string data_directory_;
atomic<encrypt_config> encrypt_config_;
atomic<host_config> host_config_;
std::string log_directory_;
mutable std::recursive_mutex read_write_mutex_;
mutable std::recursive_mutex remote_mount_mutex_;
atomic<remote::remote_config> remote_config_;
atomic<remote::remote_mount> remote_mount_;
atomic<s3_config> s3_config_;
atomic<sia_config> sia_config_;
std::unordered_map<std::string, std::function<std::string()>>
value_get_lookup_;
std::unordered_map<std::string,
std::function<std::string(const std::string &)>>
value_set_lookup_;
std::uint64_t version_{REPERTORY_CONFIG_VERSION};
private:
[[nodiscard]] auto load() -> bool;
template <typename dest>
auto get_value(const json &json_document, const std::string &name, dest &dst,
bool &success_flag) -> bool {
constexpr const auto *function_name =
static_cast<const char *>(__FUNCTION__);
auto ret = false;
try {
if (json_document.find(name) != json_document.end()) {
dst = json_document[name].get<dest>();
ret = true;
} else {
success_flag = false;
}
} catch (const json::exception &ex) {
utils::error::raise_error(function_name, ex, "exception occurred");
success_flag = false;
ret = false;
}
return ret;
}
template <typename dest, typename source>
auto set_value(dest &dst, const source &src) -> bool {
auto ret = false;
recur_mutex_lock lock(read_write_mutex_);
if (dst != src) {
dst = src;
config_changed_ = true;
save();
ret = true;
}
return ret;
}
auto set_value(dest &dst, const source &src) -> bool;
public:
[[nodiscard]] auto get_api_auth() const -> std::string { return api_auth_; }
[[nodiscard]] auto get_api_password() const -> std::string;
[[nodiscard]] auto get_api_port() const -> std::uint16_t { return api_port_; }
[[nodiscard]] auto get_api_port() const -> std::uint16_t;
[[nodiscard]] auto get_api_user() const -> std::string { return api_user_; }
[[nodiscard]] auto get_api_user() const -> std::string;
[[nodiscard]] auto get_cache_directory() const -> std::string {
return cache_directory_;
}
[[nodiscard]] auto get_chunk_downloader_timeout_secs() const -> std::uint8_t {
return std::max(min_download_timeout_secs_, download_timeout_secs_);
}
[[nodiscard]] auto get_cache_directory() const -> std::string;
[[nodiscard]] auto get_config_file_path() const -> std::string;
[[nodiscard]] auto get_data_directory() const -> std::string {
return data_directory_;
}
[[nodiscard]] auto get_database_type() const -> database_type;
[[nodiscard]] auto get_enable_chunk_download_timeout() const -> bool {
return enable_chunk_downloader_timeout_;
}
[[nodiscard]] auto get_data_directory() const -> std::string;
[[nodiscard]] auto get_enable_comm_duration_events() const -> bool {
return enable_comm_duration_events_;
}
[[nodiscard]] auto get_download_timeout_secs() const -> std::uint8_t;
[[nodiscard]] auto get_enable_drive_events() const -> bool {
return enable_drive_events_;
}
[[nodiscard]] auto get_enable_download_timeout() const -> bool;
[[nodiscard]] auto get_encrypt_config() const -> encrypt_config {
return encrypt_config_;
}
[[nodiscard]] auto get_enable_drive_events() const -> bool;
[[nodiscard]] auto get_encrypt_config() const -> encrypt_config;
#if defined(_WIN32)
[[nodiscard]] auto get_enable_mount_manager() const -> bool {
return enable_mount_manager_;
}
#endif
[[nodiscard]] auto get_enable_mount_manager() const -> bool;
#endif // defined(_WIN32)
[[nodiscard]] auto get_enable_max_cache_size() const -> bool {
return enable_max_cache_size_;
}
[[nodiscard]] auto get_event_level() const -> event_level;
[[nodiscard]] auto get_enable_remote_mount() const -> bool {
return enable_remote_mount_;
}
[[nodiscard]] auto get_eviction_delay_mins() const -> std::uint32_t;
[[nodiscard]] auto get_event_level() const -> event_level {
return event_level_;
}
[[nodiscard]] auto get_eviction_uses_accessed_time() const -> bool;
[[nodiscard]] auto get_eviction_delay_mins() const -> std::uint32_t {
return eviction_delay_mins_;
}
[[nodiscard]] auto get_high_frequency_interval_secs() const -> std::uint16_t;
[[nodiscard]] auto get_eviction_uses_accessed_time() const -> bool {
return eviction_uses_accessed_time_;
}
[[nodiscard]] auto get_high_frequency_interval_secs() const -> std::uint8_t {
return std::max(static_cast<std::uint8_t>(1U), high_freq_interval_secs_);
}
[[nodiscard]] auto get_host_config() const -> host_config { return hc_; }
[[nodiscard]] auto get_is_remote_mount() const -> bool {
return is_remote_mount_;
}
[[nodiscard]] auto get_host_config() const -> host_config;
[[nodiscard]] auto get_json() const -> json;
[[nodiscard]] auto get_log_directory() const -> std::string {
return log_directory_;
}
[[nodiscard]] auto get_log_directory() const -> std::string;
[[nodiscard]] auto get_low_frequency_interval_secs() const -> std::uint32_t {
return std::max(1U, low_freq_interval_secs_);
}
[[nodiscard]] auto get_low_frequency_interval_secs() const -> std::uint16_t;
[[nodiscard]] auto get_max_cache_size_bytes() const -> std::uint64_t;
[[nodiscard]] auto get_max_upload_count() const -> std::uint8_t {
return std::max(std::uint8_t(1U), max_upload_count_);
}
[[nodiscard]] auto get_max_upload_count() const -> std::uint8_t;
[[nodiscard]] auto get_online_check_retry_secs() const -> std::uint16_t {
return std::max(std::uint16_t(15U), online_check_retry_secs_);
}
[[nodiscard]] auto get_med_frequency_interval_secs() const -> std::uint16_t;
[[nodiscard]] auto get_orphaned_file_retention_days() const -> std::uint16_t {
return std::min(static_cast<std::uint16_t>(31U),
std::max(static_cast<std::uint16_t>(1U),
orphaned_file_retention_days_));
}
[[nodiscard]] auto get_online_check_retry_secs() const -> std::uint16_t;
[[nodiscard]] auto get_preferred_download_type() const -> download_type {
return download_type_from_string(preferred_download_type_,
download_type::fallback);
}
[[nodiscard]] auto get_preferred_download_type() const -> download_type;
[[nodiscard]] auto get_provider_type() const -> provider_type {
return prov_;
}
[[nodiscard]] auto get_provider_type() const -> provider_type;
[[nodiscard]] auto get_read_ahead_count() const -> std::uint8_t {
return std::max(static_cast<std::uint8_t>(1U), read_ahead_count_);
}
[[nodiscard]] auto get_remote_config() const -> remote::remote_config;
[[nodiscard]] auto get_remote_client_pool_size() const -> std::uint8_t {
return std::max(static_cast<std::uint8_t>(5U), remote_client_pool_size_);
}
[[nodiscard]] auto get_remote_mount() const -> remote::remote_mount;
[[nodiscard]] auto get_remote_host_name_or_ip() const -> std::string {
return remote_host_name_or_ip_;
}
[[nodiscard]] auto get_retry_read_count() const -> std::uint16_t;
[[nodiscard]] auto get_remote_max_connections() const -> std::uint8_t {
return std::max(static_cast<std::uint8_t>(1U), remote_max_connections_);
}
[[nodiscard]] auto get_ring_buffer_file_size() const -> std::uint16_t;
[[nodiscard]] auto get_remote_port() const -> std::uint16_t {
return remote_port_;
}
[[nodiscard]] auto get_s3_config() const -> s3_config;
[[nodiscard]] auto get_remote_receive_timeout_secs() const -> std::uint16_t {
return remote_receive_timeout_secs_;
}
[[nodiscard]] auto get_sia_config() const -> sia_config;
[[nodiscard]] auto get_remote_send_timeout_secs() const -> std::uint16_t {
return remote_send_timeout_secs_;
}
[[nodiscard]] auto get_task_wait_ms() const -> std::uint16_t;
[[nodiscard]] auto get_remote_token() const -> std::string {
return remote_token_;
}
[[nodiscard]] auto get_value_by_name(const std::string &name) const
-> std::string;
[[nodiscard]] auto get_retry_read_count() const -> std::uint16_t {
return std::max(std::uint16_t(2), retry_read_count_);
}
[[nodiscard]] auto get_raw_value_by_name(const std::string &name) const
-> std::string;
[[nodiscard]] auto get_ring_buffer_file_size() const -> std::uint16_t {
return std::max(
static_cast<std::uint16_t>(64U),
std::min(static_cast<std::uint16_t>(1024U), ring_buffer_file_size_));
}
[[nodiscard]] auto get_s3_config() const -> s3_config { return s3_config_; }
[[nodiscard]] auto get_sia_config() const -> sia_config {
return sia_config_;
}
[[nodiscard]] auto get_value_by_name(const std::string &name) -> std::string;
[[nodiscard]] auto get_version() const -> std::uint64_t { return version_; }
[[nodiscard]] auto get_version() const -> std::uint64_t;
void save();
void set_api_auth(const std::string &api_auth) {
set_value(api_auth_, api_auth);
}
void set_api_password(const std::string &value);
void set_api_port(std::uint16_t api_port) { set_value(api_port_, api_port); }
void set_api_port(std::uint16_t value);
void set_api_user(const std::string &api_user) {
set_value(api_user_, api_user);
}
void set_api_user(const std::string &value);
void set_chunk_downloader_timeout_secs(
std::uint8_t chunk_downloader_timeout_secs) {
set_value(download_timeout_secs_, chunk_downloader_timeout_secs);
}
void set_download_timeout_secs(std::uint8_t value);
void
set_enable_chunk_downloader_timeout(bool enable_chunk_downloader_timeout) {
set_value(enable_chunk_downloader_timeout_,
enable_chunk_downloader_timeout);
}
void set_database_type(const database_type &value);
void set_enable_comm_duration_events(bool enable_comm_duration_events) {
set_value(enable_comm_duration_events_, enable_comm_duration_events);
}
void set_enable_download_timeout(bool value);
void set_enable_drive_events(bool enable_drive_events) {
set_value(enable_drive_events_, enable_drive_events);
}
void set_enable_max_cache_size(bool enable_max_cache_size) {
set_value(enable_max_cache_size_, enable_max_cache_size);
}
void set_enable_drive_events(bool value);
#if defined(_WIN32)
void set_enable_mount_manager(bool enable_mount_manager) {
set_value(enable_mount_manager_, enable_mount_manager);
}
#endif
void set_enable_mount_manager(bool value);
#endif // defined(_WIN32)
void set_enable_remote_mount(bool enable_remote_mount);
void set_event_level(const event_level &value);
void set_event_level(const event_level &level) {
if (set_value(event_level_, level)) {
event_system::instance().raise<event_level_changed>(
event_level_to_string(level));
}
}
void set_encrypt_config(encrypt_config value);
void set_eviction_delay_mins(std::uint32_t eviction_delay_mins) {
set_value(eviction_delay_mins_, eviction_delay_mins);
}
void set_eviction_delay_mins(std::uint32_t value);
void set_eviction_uses_accessed_time(bool eviction_uses_accessed_time) {
set_value(eviction_uses_accessed_time_, eviction_uses_accessed_time);
}
void set_eviction_uses_accessed_time(bool value);
void
set_high_frequency_interval_secs(std::uint8_t high_frequency_interval_secs) {
set_value(high_freq_interval_secs_, high_frequency_interval_secs);
}
void set_high_frequency_interval_secs(std::uint16_t value);
#if defined(PROJECT_TESTING)
void set_host_config(host_config hc) {
config_changed_ = true;
hc_ = std::move(hc);
save();
}
void set_host_config(host_config value);
void set_s3_config(s3_config s3) {
config_changed_ = true;
s3_config_ = std::move(s3);
save();
}
#endif
void set_low_frequency_interval_secs(std::uint16_t value);
void set_is_remote_mount(bool is_remote_mount);
void set_max_cache_size_bytes(std::uint64_t value);
void
set_low_frequency_interval_secs(std::uint32_t low_frequency_interval_secs) {
set_value(low_freq_interval_secs_, low_frequency_interval_secs);
}
void set_max_upload_count(std::uint8_t value);
void set_max_cache_size_bytes(std::uint64_t max_cache_size_bytes) {
set_value(max_cache_size_bytes_, max_cache_size_bytes);
}
void set_med_frequency_interval_secs(std::uint16_t value);
void set_max_upload_count(std::uint8_t max_upload_count) {
set_value(max_upload_count_, max_upload_count);
}
void set_online_check_retry_secs(std::uint16_t value);
void set_online_check_retry_secs(std::uint16_t online_check_retry_secs) {
set_value(online_check_retry_secs_, online_check_retry_secs);
}
void set_preferred_download_type(const download_type &value);
void
set_orphaned_file_retention_days(std::uint16_t orphaned_file_retention_days) {
set_value(orphaned_file_retention_days_, orphaned_file_retention_days);
}
void set_remote_config(remote::remote_config value);
void set_preferred_download_type(const download_type &dt) {
set_value(preferred_download_type_, download_type_to_string(dt));
}
void set_remote_mount(remote::remote_mount value);
void set_read_ahead_count(std::uint8_t read_ahead_count) {
set_value(read_ahead_count_, read_ahead_count);
}
void set_retry_read_count(std::uint16_t value);
void set_remote_client_pool_size(std::uint8_t remote_client_pool_size) {
set_value(remote_client_pool_size_, remote_client_pool_size);
}
void set_ring_buffer_file_size(std::uint16_t value);
void set_ring_buffer_file_size(std::uint16_t ring_buffer_file_size) {
set_value(ring_buffer_file_size_, ring_buffer_file_size);
}
void set_s3_config(s3_config value);
void set_remote_host_name_or_ip(const std::string &remote_host_name_or_ip) {
set_value(remote_host_name_or_ip_, remote_host_name_or_ip);
}
void set_sia_config(sia_config value);
void set_remote_max_connections(std::uint8_t remote_max_connections) {
set_value(remote_max_connections_, remote_max_connections);
}
void set_remote_port(std::uint16_t remote_port) {
set_value(remote_port_, remote_port);
}
void
set_remote_receive_timeout_secs(std::uint16_t remote_receive_timeout_secs) {
set_value(remote_receive_timeout_secs_, remote_receive_timeout_secs);
}
void set_remote_send_timeout_secs(std::uint16_t remote_send_timeout_secs) {
set_value(remote_send_timeout_secs_, remote_send_timeout_secs);
}
void set_remote_token(const std::string &remote_token) {
set_value(remote_token_, remote_token);
}
void set_retry_read_count(std::uint16_t retry_read_count) {
set_value(retry_read_count_, retry_read_count);
}
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;
};
} // namespace repertory
#endif // INCLUDE_APP_CONFIG_HPP_
#endif // REPERTORY_INCLUDE_APP_CONFIG_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,13 +19,14 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_CURL_COMM_HPP_
#define INCLUDE_COMM_CURL_CURL_COMM_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_CURL_COMM_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_CURL_COMM_HPP_
#include "app_config.hpp"
#include "comm/curl/multi_request.hpp"
#include "comm/i_http_comm.hpp"
#include "events/event_system.hpp"
#include "events/events.hpp"
#include "events/types/curl_error.hpp"
#include "utils/encryption.hpp"
namespace repertory {
@ -42,7 +43,7 @@ private:
struct read_write_info final {
data_buffer data{};
stop_type &stop_requested;
stop_type_callback stop_requested_cb;
};
static const write_callback write_data;
@ -61,13 +62,14 @@ public:
[[nodiscard]] static auto reset_curl(CURL *curl_handle) -> CURL *;
public:
[[nodiscard]] static auto
construct_url(CURL *curl, const std::string &relative_path,
const host_config &cfg) -> std::string;
[[nodiscard]] static auto construct_url(CURL *curl,
const std::string &relative_path,
const host_config &cfg)
-> std::string;
[[nodiscard]] static auto
create_host_config(const s3_config &cfg,
bool use_s3_path_style) -> host_config;
[[nodiscard]] static auto create_host_config(const s3_config &cfg,
bool use_s3_path_style)
-> host_config;
[[nodiscard]] static auto url_encode(CURL *curl, const std::string &data,
bool allow_slash) -> std::string;
@ -75,8 +77,8 @@ public:
template <typename request_type>
[[nodiscard]] static auto
make_encrypted_request(const host_config &cfg, const request_type &request,
long &response_code,
stop_type &stop_requested) -> bool {
long &response_code, stop_type &stop_requested)
-> bool {
response_code = 0;
if (not request.decryption_token.has_value() ||
@ -114,7 +116,7 @@ public:
return false;
}
if (response_code != 200) {
if (response_code != http_error_codes::ok) {
return false;
}
@ -135,6 +137,8 @@ public:
[[nodiscard]] static auto
make_request(const host_config &cfg, const request_type &request,
long &response_code, stop_type &stop_requested) -> bool {
REPERTORY_USES_FUNCTION_NAME();
if (request.decryption_token.has_value() &&
not request.decryption_token.value().empty()) {
return make_encrypted_request(cfg, request, response_code,
@ -169,7 +173,12 @@ public:
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_headers);
}
read_write_info write_info{{}, stop_requested};
read_write_info write_info{
{},
[&stop_requested]() -> bool {
return stop_requested || app_config::get_stop_requested();
},
};
if (request.response_handler.has_value()) {
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_info);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
@ -193,6 +202,16 @@ public:
request.aws_service.value().c_str());
}
curl_slist *header_list{nullptr};
if (not request.headers.empty()) {
for (const auto &header : request.headers) {
header_list = curl_slist_append(
header_list,
fmt::format("{}: {}", header.first, header.second).c_str());
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list);
}
auto url = construct_url(curl, request.get_path(), cfg) + parameters;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@ -200,8 +219,14 @@ public:
CURLcode curl_code{};
curl_request.get_result(curl_code, response_code);
if (header_list != nullptr) {
curl_slist_free_all(header_list);
}
if (curl_code != CURLE_OK) {
event_system::instance().raise<curl_error>(url, curl_code);
event_system::instance().raise<curl_error>(curl_code, function_name,
url);
return false;
}
@ -215,27 +240,31 @@ public:
public:
void enable_s3_path_style(bool enable) override;
[[nodiscard]] auto
make_request(const curl::requests::http_delete &del, long &response_code,
stop_type &stop_requested) const -> bool override;
[[nodiscard]] auto
make_request(const curl::requests::http_get &get, long &response_code,
stop_type &stop_requested) const -> bool override;
[[nodiscard]] auto
make_request(const curl::requests::http_head &head, long &response_code,
stop_type &stop_requested) const -> bool override;
[[nodiscard]] auto
make_request(const curl::requests::http_post &post_file, long &response_code,
stop_type &stop_requested) const -> bool override;
[[nodiscard]] auto
make_request(const curl::requests::http_put_file &put_file,
[[nodiscard]] auto make_request(const curl::requests::http_delete &del,
long &response_code,
stop_type &stop_requested) const -> bool override;
stop_type &stop_requested) const
-> bool override;
[[nodiscard]] auto make_request(const curl::requests::http_get &get,
long &response_code,
stop_type &stop_requested) const
-> bool override;
[[nodiscard]] auto make_request(const curl::requests::http_head &head,
long &response_code,
stop_type &stop_requested) const
-> bool override;
[[nodiscard]] auto make_request(const curl::requests::http_post &post_file,
long &response_code,
stop_type &stop_requested) const
-> bool override;
[[nodiscard]] auto make_request(const curl::requests::http_put_file &put_file,
long &response_code,
stop_type &stop_requested) const
-> bool override;
};
} // namespace repertory
#endif // INCLUDE_COMM_CURL_CURL_COMM_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_CURL_COMM_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
#define INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
#include "types/repertory.hpp"
@ -36,9 +36,12 @@ private:
stop_type &stop_requested_;
CURLM *multi_handle_;
private:
[[nodiscard]] auto get_stop_requested() const -> bool;
public:
void get_result(CURLcode &curl_code, long &http_code);
};
} // namespace repertory
#endif // INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_DELETE_HPP_
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_DELETE_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_DELETE_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_DELETE_HPP_
#include "comm/curl/requests/http_request_base.hpp"
@ -28,13 +28,13 @@ namespace repertory::curl::requests {
struct http_delete final : http_request_base {
~http_delete() override = default;
[[nodiscard]] auto set_method(CURL *curl,
stop_type & /* stop_requested */) const
-> bool override {
[[nodiscard]] auto
set_method(CURL *curl,
stop_type & /* stop_requested */) const -> bool override {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
return true;
}
};
} // namespace repertory::curl::requests
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_DELETE_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_DELETE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_GET_HPP_
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_GET_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_GET_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_GET_HPP_
#include "comm/curl/requests/http_request_base.hpp"
@ -33,13 +33,13 @@ struct http_get final : http_request_base {
auto operator=(http_get &&) -> http_get & = default;
~http_get() override = default;
[[nodiscard]] auto set_method(CURL *curl,
stop_type & /*stop_requested*/) const
-> bool override {
[[nodiscard]] auto
set_method(CURL *curl,
stop_type & /*stop_requested*/) const -> bool override {
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
return true;
}
};
} // namespace repertory::curl::requests
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_GET_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_GET_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_HEAD_HPP_
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_HEAD_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_HEAD_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_HEAD_HPP_
#include "comm/curl/requests/http_request_base.hpp"
@ -28,9 +28,9 @@ namespace repertory::curl::requests {
struct http_head final : http_request_base {
~http_head() override = default;
[[nodiscard]] auto set_method(CURL *curl,
stop_type & /* stop_requested */) const
-> bool override {
[[nodiscard]] auto
set_method(CURL *curl,
stop_type & /* stop_requested */) const -> bool override {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "HEAD");
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
return true;
@ -38,4 +38,4 @@ struct http_head final : http_request_base {
};
} // namespace repertory::curl::requests
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_HEAD_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_HEAD_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_POST_HPP_
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_POST_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_POST_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_POST_HPP_
#include "comm/curl/requests/http_request_base.hpp"
@ -32,7 +32,7 @@ struct http_post final : http_request_base {
auto operator=(const http_post &) -> http_post & = default;
auto operator=(http_post &&) -> http_post & = default;
~http_post() override;
~http_post() override = default;
std::optional<nlohmann::json> json;
@ -41,9 +41,8 @@ struct http_post final : http_request_base {
-> bool override;
private:
mutable curl_slist *headers{nullptr};
mutable std::optional<std::string> json_str;
};
} // namespace repertory::curl::requests
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_POST_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_POST_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
#include "comm/curl/requests/http_request_base.hpp"
#include "utils/encrypting_reader.hpp"
@ -47,4 +47,4 @@ private:
};
} // namespace repertory::curl::requests
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_PUT_FILE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,16 +19,14 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
#include "types/repertory.hpp"
#include "utils/file.hpp"
namespace repertory::curl::requests {
using read_callback = size_t (*)(char *, size_t, size_t, void *);
using response_callback =
using curl_response_callback =
std::function<void(const data_buffer &data, long response_code)>;
struct read_file_info final {
@ -37,19 +35,8 @@ struct read_file_info final {
std::uint64_t offset{};
};
inline const auto read_file_data = static_cast<read_callback>(
[](char *buffer, size_t size, size_t nitems, void *instream) -> size_t {
auto *read_info = reinterpret_cast<read_file_info *>(instream);
std::size_t bytes_read{};
auto ret =
read_info->file->read(reinterpret_cast<unsigned char *>(buffer),
size * nitems, read_info->offset, &bytes_read);
if (ret) {
read_info->offset += bytes_read;
}
return ret && not read_info->stop_requested ? bytes_read
: CURL_READFUNC_ABORT;
});
[[nodiscard]] auto curl_file_reader(char *buffer, size_t size, size_t nitems,
void *instream) -> size_t;
struct http_request_base {
http_request_base() = default;
@ -64,19 +51,20 @@ struct http_request_base {
bool allow_timeout{};
std::optional<std::string> aws_service;
std::optional<std::string> decryption_token{};
http_headers headers{};
mutable http_headers headers{};
std::string path{};
http_query_parameters query{};
std::optional<http_range> range{};
std::optional<response_callback> response_handler;
std::optional<curl_response_callback> response_handler;
std::optional<http_headers> response_headers;
std::optional<std::uint64_t> total_size{};
[[nodiscard]] virtual auto get_path() const -> std::string { return path; }
[[nodiscard]] virtual auto
set_method(CURL *curl, stop_type &stop_requested) const -> bool = 0;
[[nodiscard]] virtual auto set_method(CURL *curl,
stop_type &stop_requested) const
-> bool = 0;
};
} // namespace repertory::curl::requests
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
#endif // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_I_HTTP_COMM_HPP_
#define INCLUDE_COMM_I_HTTP_COMM_HPP_
#ifndef REPERTORY_INCLUDE_COMM_I_HTTP_COMM_HPP_
#define REPERTORY_INCLUDE_COMM_I_HTTP_COMM_HPP_
#include "comm/curl/requests/http_delete.hpp"
#include "comm/curl/requests/http_get.hpp"
@ -40,26 +40,23 @@ public:
make_request(const curl::requests::http_delete &del, long &response_code,
stop_type &stop_requested) const -> bool = 0;
[[nodiscard]] virtual auto make_request(const curl::requests::http_get &get,
long &response_code,
stop_type &stop_requested) const
-> bool = 0;
[[nodiscard]] virtual auto
make_request(const curl::requests::http_get &get, long &response_code,
stop_type &stop_requested) const -> bool = 0;
[[nodiscard]] virtual auto make_request(const curl::requests::http_head &head,
long &response_code,
stop_type &stop_requested) const
-> bool = 0;
[[nodiscard]] virtual auto
make_request(const curl::requests::http_head &head, long &response_code,
stop_type &stop_requested) const -> bool = 0;
[[nodiscard]] virtual auto make_request(const curl::requests::http_post &post,
long &response_code,
stop_type &stop_requested) const
-> bool = 0;
[[nodiscard]] virtual auto
make_request(const curl::requests::http_post &post, long &response_code,
stop_type &stop_requested) const -> bool = 0;
[[nodiscard]] virtual auto
make_request(const curl::requests::http_put_file &put_file,
long &response_code, stop_type &stop_requested) const
-> bool = 0;
long &response_code,
stop_type &stop_requested) const -> bool = 0;
};
} // namespace repertory
#endif // INCLUDE_COMM_I_HTTP_COMM_HPP_
#endif // REPERTORY_INCLUDE_COMM_I_HTTP_COMM_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
#define INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
#ifndef REPERTORY_INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
#define REPERTORY_INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
#include "comm/packet/packet.hpp"
#include "types/repertory.hpp"
@ -107,4 +107,4 @@ public:
};
} // namespace repertory
#endif // INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
#endif // REPERTORY_INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_PACKET_PACKET_HPP_
#define INCLUDE_COMM_PACKET_PACKET_HPP_
#ifndef REPERTORY_INCLUDE_COMM_PACKET_PACKET_HPP_
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_HPP_
#include "types/remote.hpp"
#include "types/repertory.hpp"
@ -52,23 +52,23 @@ public:
~packet() = default;
private:
data_buffer buffer_;
std::size_t decode_offset_ = 0U;
data_buffer buffer_{};
std::size_t decode_offset_{0U};
public:
[[nodiscard]] static auto decode_json(packet &response,
json &json_data) -> int;
[[nodiscard]] static auto decode_json(packet &response, json &json_data)
-> int;
public:
void clear();
[[nodiscard]] auto current_pointer() -> unsigned char * {
return (decode_offset_ < buffer_.size()) ? &buffer_[decode_offset_]
return (decode_offset_ < buffer_.size()) ? &buffer_.at(decode_offset_)
: nullptr;
}
[[nodiscard]] auto current_pointer() const -> const unsigned char * {
return (decode_offset_ < buffer_.size()) ? &buffer_[decode_offset_]
return (decode_offset_ < buffer_.size()) ? &buffer_.at(decode_offset_)
: nullptr;
}
@ -206,7 +206,7 @@ public:
return static_cast<std::uint32_t>(buffer_.size());
}
void transfer_into(data_buffer &buffer);
void to_buffer(data_buffer &buffer);
public:
auto operator=(const data_buffer &buffer) noexcept -> packet &;
@ -226,8 +226,6 @@ public:
return buffer_.at(index);
}
};
using packet = packet;
} // namespace repertory
#endif // INCLUDE_COMM_PACKET_PACKET_HPP_
#endif // REPERTORY_INCLUDE_COMM_PACKET_PACKET_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,10 +19,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
#define INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
#ifndef REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
#include "comm/packet/packet.hpp"
#include "types/remote.hpp"
using boost::asio::ip::tcp;
@ -36,9 +37,7 @@ private:
};
public:
packet_client(std::string host_name_or_ip, std::uint8_t max_connections,
std::uint16_t port, std::uint16_t receive_timeout,
std::uint16_t send_timeout, std::string encryption_token);
packet_client(remote::remote_config cfg);
~packet_client();
@ -49,12 +48,7 @@ public:
private:
boost::asio::io_context io_context_;
std::string host_name_or_ip_;
std::uint8_t max_connections_;
std::uint16_t port_;
std::uint16_t receive_timeout_;
std::uint16_t send_timeout_;
std::string encryption_token_;
remote::remote_config cfg_;
std::string unique_id_;
private:
@ -76,7 +70,7 @@ private:
void put_client(std::shared_ptr<client> &cli);
[[nodiscard]] auto read_packet(client &cli,
packet &response) -> packet::error_type;
packet &response) const -> packet::error_type;
void resolve();
@ -93,4 +87,4 @@ public:
};
} // namespace repertory
#endif // INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
#endif // REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
#define INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
#ifndef REPERTORY_INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
#include "comm/packet/client_pool.hpp"
#include "utils/common.hpp"
@ -52,8 +52,8 @@ public:
private:
struct connection {
connection(boost::asio::io_service &io_service, tcp::acceptor &acceptor_)
: socket(io_service), acceptor(acceptor_) {}
connection(io_context &ctx, tcp::acceptor &acceptor_)
: socket(ctx), acceptor(acceptor_) {}
tcp::socket socket;
tcp::acceptor &acceptor;
@ -68,7 +68,7 @@ private:
std::string encryption_token_;
closed_callback closed_;
message_handler_callback message_handler_;
boost::asio::io_context io_context_;
io_context io_context_;
std::unique_ptr<std::thread> server_thread_;
std::vector<std::thread> service_threads_;
std::recursive_mutex connection_mutex_;
@ -95,4 +95,4 @@ private:
};
} // namespace repertory
#endif // INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
#endif // REPERTORY_INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMMON_HPP_
#define INCLUDE_COMMON_HPP_
#ifndef REPERTORY_INCLUDE_COMMON_HPP_
#define REPERTORY_INCLUDE_COMMON_HPP_
#if defined(__GNUC__)
// clang-format off
@ -57,7 +57,7 @@ using json = nlohmann::json;
inline constexpr const std::string_view REPERTORY = "repertory";
inline constexpr const std::wstring_view REPERTORY_W = L"repertory";
inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION = 0ULL;
inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION = 2ULL;
inline constexpr const std::string_view REPERTORY_DATA_NAME = "repertory2";
inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION = "2.0.0";
@ -221,44 +221,25 @@ using WCHAR = wchar_t;
#define MAX_PATH 260
#define STATUS_SUCCESS \
std::uint32_t { 0U }
#define STATUS_ACCESS_DENIED \
std::uint32_t { 0xC0000022L }
#define STATUS_DEVICE_BUSY \
std::uint32_t { 0x80000011L }
#define STATUS_DEVICE_INSUFFICIENT_RESOURCES \
std::uint32_t { 0xC0000468L }
#define STATUS_DIRECTORY_NOT_EMPTY \
std::uint32_t { 0xC0000101L }
#define STATUS_FILE_IS_A_DIRECTORY \
std::uint32_t { 0xC00000BAL }
#define STATUS_FILE_TOO_LARGE \
std::uint32_t { 0xC0000904L }
#define STATUS_INSUFFICIENT_RESOURCES \
std::uint32_t { 0xC000009AL }
#define STATUS_INTERNAL_ERROR \
std::uint32_t { 0xC00000E5L }
#define STATUS_INVALID_ADDRESS \
std::uint32_t { 0xC0000141L }
#define STATUS_INVALID_HANDLE \
std::uint32_t { 0xC0000006L }
#define STATUS_INVALID_IMAGE_FORMAT \
std::uint32_t { 0xC000007BL }
#define STATUS_INVALID_PARAMETER \
std::uint32_t { 0xC000000DL }
#define STATUS_NO_MEMORY \
std::uint32_t { 0xC0000017L }
#define STATUS_NOT_IMPLEMENTED \
std::uint32_t { 0xC0000002L }
#define STATUS_OBJECT_NAME_EXISTS \
std::uint32_t { 0x40000000L }
#define STATUS_OBJECT_NAME_NOT_FOUND \
std::uint32_t { 0xC0000034L }
#define STATUS_OBJECT_PATH_INVALID \
std::uint32_t { 0xC0000039L }
#define STATUS_UNEXPECTED_IO_ERROR \
std::uint32_t { 0xC00000E9L }
#define STATUS_SUCCESS std::uint32_t{0U}
#define STATUS_ACCESS_DENIED std::uint32_t{0xC0000022L}
#define STATUS_DEVICE_BUSY std::uint32_t{0x80000011L}
#define STATUS_DEVICE_INSUFFICIENT_RESOURCES std::uint32_t{0xC0000468L}
#define STATUS_DIRECTORY_NOT_EMPTY std::uint32_t{0xC0000101L}
#define STATUS_FILE_IS_A_DIRECTORY std::uint32_t{0xC00000BAL}
#define STATUS_FILE_TOO_LARGE std::uint32_t{0xC0000904L}
#define STATUS_INSUFFICIENT_RESOURCES std::uint32_t{0xC000009AL}
#define STATUS_INTERNAL_ERROR std::uint32_t{0xC00000E5L}
#define STATUS_INVALID_ADDRESS std::uint32_t{0xC0000141L}
#define STATUS_INVALID_HANDLE std::uint32_t{0xC0000006L}
#define STATUS_INVALID_IMAGE_FORMAT std::uint32_t{0xC000007BL}
#define STATUS_INVALID_PARAMETER std::uint32_t{0xC000000DL}
#define STATUS_NO_MEMORY std::uint32_t{0xC0000017L}
#define STATUS_NOT_IMPLEMENTED std::uint32_t{0xC0000002L}
#define STATUS_OBJECT_NAME_EXISTS std::uint32_t{0x40000000L}
#define STATUS_OBJECT_NAME_NOT_FOUND std::uint32_t{0xC0000034L}
#define STATUS_OBJECT_PATH_INVALID std::uint32_t{0xC0000039L}
#define STATUS_UNEXPECTED_IO_ERROR std::uint32_t{0xC00000E9L}
#define CONVERT_STATUS_NOT_IMPLEMENTED(e) \
((std::uint32_t(e) == STATUS_NOT_IMPLEMENTED) ? -ENOTSUP : e)
@ -296,8 +277,8 @@ using namespace Fsp;
#define INTERFACE_SETUP(name) \
public: \
name(const name &) noexcept = delete; \
name &operator=(const name &) noexcept = delete; \
name &operator=(name &&) noexcept = delete; \
auto operator=(const name &) noexcept -> name & = delete; \
auto operator=(name &&) noexcept -> name & = delete; \
\
protected: \
name() = default; \
@ -307,4 +288,4 @@ public: \
virtual ~name() = default
#endif // __cplusplus
#endif // INCLUDE_COMMON_HPP_
#endif // REPERTORY_INCLUDE_COMMON_HPP_

View File

@ -1,227 +0,0 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 INCLUDE_DATABASE_DB_COMMON_HPP_
#define INCLUDE_DATABASE_DB_COMMON_HPP_
#include "utils/error_utils.hpp"
namespace repertory::db {
using db_types_t = std::variant<std::int64_t, std::string>;
struct sqlite3_deleter {
void operator()(sqlite3 *db3) {
if (db3 != nullptr) {
sqlite3_close_v2(db3);
}
}
};
using db3_t = std::unique_ptr<sqlite3, sqlite3_deleter>;
struct sqlite3_statement_deleter {
void operator()(sqlite3_stmt *stmt) {
if (stmt != nullptr) {
sqlite3_finalize(stmt);
}
}
};
using db3_stmt_t = std::unique_ptr<sqlite3_stmt, sqlite3_statement_deleter>;
[[nodiscard]] auto execute_sql(sqlite3 &db3, const std::string &sql,
std::string &err) -> bool;
void set_journal_mode(sqlite3 &db3);
struct comp_data_t final {
std::string column_name;
std::string op_type;
db_types_t value;
};
class db_column final {
public:
db_column() noexcept = default;
db_column(const db_column &) = default;
db_column(db_column &&column) noexcept = default;
~db_column() = default;
auto operator=(const db_column &) -> db_column & = default;
auto operator=(db_column &&) -> db_column & = default;
db_column(std::int32_t index, std::string name, db_types_t value) noexcept
: index_(index), name_(std::move(name)), value_(std::move(value)) {}
private:
std::int32_t index_{};
std::string name_;
db_types_t value_;
public:
[[nodiscard]] auto get_index() const -> std::int32_t { return index_; }
[[nodiscard]] auto get_name() const -> std::string { return name_; }
template <typename data_type>
[[nodiscard]] auto get_value() const -> data_type {
return std::visit(
overloaded{
[](const data_type &value) -> data_type { return value; },
[](auto &&) -> data_type {
throw std::runtime_error("data type not supported");
},
},
value_);
}
[[nodiscard]] auto get_value_as_json() const -> nlohmann::json {
return std::visit(
overloaded{
[this](std::int64_t value) -> auto {
return nlohmann::json({{name_, value}});
},
[](auto &&value) -> auto { return nlohmann::json::parse(value); },
},
value_);
}
};
template <typename ctx_t> class db_row final {
public:
db_row(std::shared_ptr<ctx_t> context) {
auto column_count = sqlite3_column_count(context->stmt.get());
for (std::int32_t col = 0; col < column_count; col++) {
std::string name{sqlite3_column_name(context->stmt.get(), col)};
auto column_type = sqlite3_column_type(context->stmt.get(), col);
db_types_t value;
switch (column_type) {
case SQLITE_INTEGER: {
value = sqlite3_column_int64(context->stmt.get(), col);
} break;
case SQLITE_TEXT: {
const auto *text = reinterpret_cast<const char *>(
sqlite3_column_text(context->stmt.get(), col));
value = std::string(text == nullptr ? "" : text);
} break;
default:
throw std::runtime_error("column type not implemented|" + name + '|' +
std::to_string(column_type));
}
columns_[name] = db_column{col, name, value};
}
}
private:
std::map<std::string, db_column> columns_;
public:
[[nodiscard]] auto get_columns() const -> std::vector<db_column> {
std::vector<db_column> ret;
for (const auto &item : columns_) {
ret.push_back(item.second);
}
return ret;
}
[[nodiscard]] auto get_column(std::int32_t index) const -> db_column {
auto iter = std::find_if(columns_.begin(), columns_.end(),
[&index](auto &&col) -> bool {
return col.second.get_index() == index;
});
if (iter == columns_.end()) {
throw std::out_of_range("");
}
return iter->second;
}
[[nodiscard]] auto get_column(std::string name) const -> db_column {
return columns_.at(name);
}
};
template <typename ctx_t> struct db_result final {
db_result(std::shared_ptr<ctx_t> context, std::int32_t res)
: context_(std::move(context)), res_(res) {
constexpr const auto *function_name =
static_cast<const char *>(__FUNCTION__);
if (res == SQLITE_OK) {
set_res(sqlite3_step(context_->stmt.get()), function_name);
}
}
private:
std::shared_ptr<ctx_t> context_;
mutable std::int32_t res_;
private:
void set_res(std::int32_t res, std::string_view function) const {
if (res != SQLITE_OK && res != SQLITE_DONE && res != SQLITE_ROW) {
utils::error::raise_error(function, "failed to step|" +
std::to_string(res) + '|' +
sqlite3_errstr(res));
}
res_ = res;
}
public:
[[nodiscard]] auto ok() const -> bool {
return res_ == SQLITE_DONE || res_ == SQLITE_ROW;
}
[[nodiscard]] auto get_error() const -> std::int32_t { return res_; }
[[nodiscard]] auto get_error_str() const -> std::string {
return sqlite3_errstr(res_);
}
[[nodiscard]] auto get_row(std::optional<db_row<ctx_t>> &row) const -> bool {
constexpr const auto *function_name =
static_cast<const char *>(__FUNCTION__);
row.reset();
if (has_row()) {
row = db_row{context_};
set_res(sqlite3_step(context_->stmt.get()), function_name);
return true;
}
return false;
}
[[nodiscard]] auto has_row() const -> bool { return res_ == SQLITE_ROW; }
void next_row() const {
constexpr const auto *function_name =
static_cast<const char *>(__FUNCTION__);
if (has_row()) {
set_res(sqlite3_step(context_->stmt.get()), function_name);
}
}
};
} // namespace repertory::db
#endif // INCLUDE_DATABASE_DB_COMMON_HPP_

View File

@ -1,84 +0,0 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 INCLUDE_DATABASE_DB_SELECT_HPP_
#define INCLUDE_DATABASE_DB_SELECT_HPP_
#include "database/db_common.hpp"
#include "database/db_where_limit_t.hpp"
namespace repertory::db {
class db_select final {
public:
struct context final {
context(sqlite3 &db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {}
using w_t = db_where_with_limit_t<context, db_select>;
sqlite3 &db3;
std::string table_name;
std::vector<std::string> columns{};
std::map<std::string, std::string> count_columns{};
std::optional<std::int32_t> limit;
std::optional<std::pair<std::string, bool>> order_by;
std::optional<w_t> where;
std::vector<db_types_t *> where_values;
db3_stmt_t stmt{nullptr};
};
using row = db_row<context>;
public:
db_select(sqlite3 &db3, std::string table_name)
: context_(std::make_shared<context>(db3, table_name)) {}
db_select(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
private:
std::shared_ptr<context> context_;
public:
[[nodiscard]] auto column(std::string column_name) -> db_select &;
[[nodiscard]] auto count(std::string column_name,
std::string as_column_name) -> db_select &;
[[nodiscard]] auto dump() const -> std::string;
[[nodiscard]] auto go() const -> db_result<context>;
[[nodiscard]] auto
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
[[nodiscard]] auto limit(std::int32_t value) -> db_select &;
[[nodiscard]] auto order_by(std::string column_name,
bool ascending) -> db_select &;
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
};
} // namespace repertory::db
#endif // INCLUDE_DATABASE_DB_SELECT_HPP_

View File

@ -1,80 +0,0 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 INCLUDE_DATABASE_DB_UPDATE_HPP_
#define INCLUDE_DATABASE_DB_UPDATE_HPP_
#include "database/db_common.hpp"
#include "database/db_where_limit_t.hpp"
namespace repertory::db {
class db_update final {
public:
struct context final {
context(sqlite3 &db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {}
using w_t = db_where_with_limit_t<context, db_update>;
sqlite3 &db3;
std::string table_name;
std::map<std::string, db_types_t> column_values{};
std::optional<std::int32_t> limit;
std::optional<std::pair<std::string, bool>> order_by;
std::optional<w_t> where;
std::vector<db_types_t *> where_values;
db3_stmt_t stmt{nullptr};
};
using row = db_row<context>;
public:
db_update(sqlite3 &db3, std::string table_name)
: context_(std::make_shared<context>(db3, table_name)) {}
db_update(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
private:
std::shared_ptr<context> context_;
public:
[[nodiscard]] auto column_value(std::string column_name,
db_types_t value) -> db_update &;
[[nodiscard]] auto dump() const -> std::string;
[[nodiscard]] auto go() const -> db_result<context>;
[[nodiscard]] auto
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
[[nodiscard]] auto limit(std::int32_t value) -> db_update &;
[[nodiscard]] auto order_by(std::string column_name,
bool ascending) -> db_update &;
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
};
} // namespace repertory::db
#endif // INCLUDE_DATABASE_DB_UPDATE_HPP_

View File

@ -1,216 +0,0 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 INCLUDE_DATABASE_DB_WHERE_LIMIT_T_HPP_
#define INCLUDE_DATABASE_DB_WHERE_LIMIT_T_HPP_
#include "database/db_common.hpp"
namespace repertory::db {
template <typename cn_t, typename ctx_t, typename op_t, typename w_t,
typename wn_t>
struct db_next_limit_t final {
std::shared_ptr<ctx_t> ctx;
std::string action;
w_t next{ctx};
using group_func_t = std::function<void(w_t &)>;
[[nodiscard]] auto where(std::string column_name) -> cn_t {
return next.where(column_name);
}
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
return ctx->where->dump(idx);
}
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
[[nodiscard]] auto group(group_func_t func) -> wn_t {
return next.group(std::move(func));
}
[[nodiscard]] auto limit(std::int32_t value) -> op_t {
return op_t{ctx}.limit(value);
}
[[nodiscard]] auto order_by(std::string column_name, bool ascending) -> op_t {
return op_t{ctx}.order_by(column_name, ascending);
}
};
template <typename cn_t, typename ctx_t, typename op_t, typename w_t>
struct db_where_next_limit_t final {
std::shared_ptr<ctx_t> ctx;
w_t *owner;
using n_t = db_next_limit_t<cn_t, ctx_t, op_t, w_t, db_where_next_limit_t>;
[[nodiscard]] auto and_() -> n_t & {
owner->actions.emplace_back(n_t{
ctx,
"AND",
});
return std::get<n_t>(*std::prev(owner->actions.end()));
}
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
return ctx->where->dump(idx);
}
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
[[nodiscard]] auto limit(std::int32_t value) -> op_t {
return op_t{ctx}.limit(value);
}
[[nodiscard]] auto order_by(std::string column_name, bool ascending) -> op_t {
return op_t{ctx}.order_by(column_name, ascending);
}
[[nodiscard]] auto or_() -> n_t & {
owner->actions.emplace_back(n_t{
ctx,
"OR",
});
return std::get<n_t>(*std::prev(owner->actions.end()));
}
};
template <typename ctx_t, typename op_t, typename w_t>
struct db_comp_next_limit_t final {
std::shared_ptr<ctx_t> ctx;
w_t *owner;
std::string column_name;
using wn_t = db_where_next_limit_t<db_comp_next_limit_t, ctx_t, op_t, w_t>;
[[nodiscard]] auto create(std::string operation, db::db_types_t value) {
owner->actions.emplace_back(comp_data_t{
column_name,
operation,
value,
});
ctx->where_values.push_back(
&std::get<comp_data_t>(*std::prev(owner->actions.end())).value);
return wn_t{
ctx,
owner,
};
}
auto equals(db::db_types_t value) -> wn_t { return create("=", value); };
auto gt(db::db_types_t value) -> wn_t { return create(">", value); }
auto gte(db::db_types_t value) -> wn_t { return create(">=", value); }
auto like(db::db_types_t value) -> wn_t { return create("LIKE", value); }
auto lt(db::db_types_t value) -> wn_t { return create("<", value); }
auto lte(db::db_types_t value) -> wn_t { return create("<=", value); }
auto not_equals(db::db_types_t value) -> wn_t { return create("!=", value); };
};
template <typename ctx_t, typename op_t> struct db_where_with_limit_t final {
std::shared_ptr<ctx_t> ctx;
using cn_t = db_comp_next_limit_t<ctx_t, op_t, db_where_with_limit_t>;
using wn_t = db_where_next_limit_t<cn_t, ctx_t, op_t, db_where_with_limit_t>;
using n_t = db_next_limit_t<cn_t, ctx_t, op_t, db_where_with_limit_t, wn_t>;
using group_func_t = std::function<void(db_where_with_limit_t &)>;
using action_t = std::variant<comp_data_t, n_t, db_where_with_limit_t>;
std::vector<action_t> actions{};
[[nodiscard]] static auto dump(std::int32_t &idx,
auto &&data) -> std::string {
std::stringstream stream;
for (auto &&action : data.actions) {
std::visit(overloaded{
[&idx, &stream](const comp_data_t &comp) {
stream << '"' << comp.column_name << '"' << comp.op_type
<< '?' + std::to_string(++idx);
},
[&idx, &stream](const n_t &next) {
stream << ' ' << next.action << ' '
<< dump(idx, next.next);
},
[&idx, &stream](const db_where_with_limit_t &where) {
stream << '(' << dump(idx, where) << ')';
},
},
action);
}
return stream.str();
}
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
return dump(idx, *this);
}
[[nodiscard]] auto group(group_func_t func) -> wn_t {
db_where_with_limit_t where{ctx};
func(where);
actions.emplace_back(std::move(where));
return wn_t{
ctx,
this,
};
}
[[nodiscard]] auto limit(std::int32_t value) -> op_t {
return op_t{ctx}.limit(value);
}
[[nodiscard]] auto order_by(std::string column_name, bool ascending) -> op_t {
return op_t{ctx}.order_by(column_name, ascending);
}
[[nodiscard]] auto where(std::string column_name) -> cn_t {
return cn_t{
ctx,
this,
column_name,
};
}
};
} // namespace repertory::db
#endif // INCLUDE_DATABASE_DB_WHERE_LIMIT_T_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,18 +19,16 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "events/t_event_system.hpp"
#ifndef REPERTORY_INCLUDE_DB_FILE_DB_HPP_
#define REPERTORY_INCLUDE_DB_FILE_DB_HPP_
#include "events/event.hpp"
#include "db/i_file_db.hpp"
namespace repertory {
template <typename event_type>
auto t_event_system<event_type>::instance() -> t_event_system<event_type> & {
return event_system_;
}
class app_config;
template <typename event_type>
t_event_system<event_type> t_event_system<event_type>::event_system_;
template class t_event_system<event>;
[[nodiscard]] auto create_file_db(const app_config &cfg)
-> std::unique_ptr<i_file_db>;
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_FILE_DB_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,23 +19,16 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_EVENTS_HPP_
#define INCLUDE_DRIVES_FUSE_EVENTS_HPP_
#ifndef REPERTORY_INCLUDE_DB_FILE_MGR_DB_HPP_
#define REPERTORY_INCLUDE_DB_FILE_MGR_DB_HPP_
#include "events/event_system.hpp"
#include "db/i_file_mgr_db.hpp"
namespace repertory {
// clang-format off
E_SIMPLE3(fuse_event, debug, true,
std::string, function, func, E_STRING,
std::string, api_path, ap, E_STRING,
int, result, res, E_FROM_INT32
);
class app_config;
E_SIMPLE1(fuse_args_parsed, info, true,
std::string, arguments, args, E_STRING
);
// clang-format on
[[nodiscard]] auto
create_file_mgr_db(const app_config &cfg) -> std::unique_ptr<i_file_mgr_db>;
} // namespace repertory
#endif // INCLUDE_DRIVES_FUSE_EVENTS_HPP_
#endif // REPERTORY_INCLUDE_DB_FILE_MGR_DB_HPP_

View File

@ -0,0 +1,100 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_I_FILE_DB_HPP_
#define REPERTORY_INCLUDE_DB_I_FILE_DB_HPP_
#include "types/repertory.hpp"
namespace repertory {
class i_file_db {
INTERFACE_SETUP(i_file_db);
public:
struct file_info final {
std::string api_path;
bool directory{};
std::string source_path;
};
struct file_data final {
std::string api_path;
std::uint64_t file_size{};
std::vector<
std::array<unsigned char, crypto_aead_xchacha20poly1305_IETF_NPUBBYTES>>
iv_list{};
std::string source_path;
};
public:
[[nodiscard]] virtual auto add_directory(const std::string &api_path,
const std::string &source_path)
-> api_error = 0;
[[nodiscard]] virtual auto add_or_update_file(const file_data &data)
-> api_error = 0;
virtual void clear() = 0;
[[nodiscard]] virtual auto count() const -> std::uint64_t = 0;
virtual void enumerate_item_list(
std::function<void(const std::vector<i_file_db::file_info> &)> callback,
stop_type_callback stop_requested_cb) const = 0;
[[nodiscard]] virtual auto get_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error = 0;
[[nodiscard]] virtual auto
get_directory_api_path(const std::string &source_path,
std::string &api_path) const -> api_error = 0;
[[nodiscard]] virtual auto
get_directory_source_path(const std::string &api_path,
std::string &source_path) const -> api_error = 0;
[[nodiscard]] virtual auto get_file_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error = 0;
[[nodiscard]] virtual auto get_file_data(const std::string &api_path,
file_data &data) const
-> api_error = 0;
[[nodiscard]] virtual auto
get_file_source_path(const std::string &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<file_info> = 0;
[[nodiscard]] virtual auto get_source_path(const std::string &api_path,
std::string &source_path) const
-> api_error = 0;
[[nodiscard]] virtual auto remove_item(const std::string &api_path)
-> api_error = 0;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_I_FILE_DB_HPP_

View File

@ -0,0 +1,83 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_I_FILE_MGR_DB_HPP_
#define REPERTORY_INCLUDE_DB_I_FILE_MGR_DB_HPP_
#include "types/repertory.hpp"
namespace repertory {
class i_file_mgr_db {
INTERFACE_SETUP(i_file_mgr_db);
public:
struct resume_entry final {
std::string api_path;
std::uint64_t chunk_size{};
boost::dynamic_bitset<> read_state;
std::string source_path;
};
struct upload_active_entry final {
std::string api_path;
std::string source_path;
};
using upload_entry = upload_active_entry;
public:
[[nodiscard]] virtual auto add_resume(const resume_entry &entry) -> bool = 0;
[[nodiscard]] virtual auto add_upload(const upload_entry &entry) -> bool = 0;
[[nodiscard]] virtual auto add_upload_active(const upload_active_entry &entry)
-> bool = 0;
virtual void clear() = 0;
[[nodiscard]] virtual auto get_next_upload() const
-> std::optional<upload_entry> = 0;
[[nodiscard]] virtual auto get_resume_list() const
-> std::vector<resume_entry> = 0;
[[nodiscard]] virtual auto get_upload(const std::string &api_path) const
-> std::optional<upload_entry> = 0;
[[nodiscard]] virtual auto get_upload_active_list() const
-> std::vector<upload_active_entry> = 0;
[[nodiscard]] virtual auto remove_resume(const std::string &api_path)
-> bool = 0;
[[nodiscard]] virtual auto remove_upload(const std::string &api_path)
-> bool = 0;
[[nodiscard]] virtual auto remove_upload_active(const std::string &api_path)
-> bool = 0;
[[nodiscard]] virtual auto rename_resume(const std::string &from_api_path,
const std::string &to_api_path)
-> bool = 0;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_I_FILE_MGR_DB_HPP_

View File

@ -0,0 +1,82 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_I_META_DB_HPP_
#define REPERTORY_INCLUDE_DB_I_META_DB_HPP_
#include "types/repertory.hpp"
namespace repertory {
class i_meta_db {
INTERFACE_SETUP(i_meta_db);
public:
virtual void clear() = 0;
virtual void enumerate_api_path_list(
std::function<void(const std::vector<std::string> &)> callback,
stop_type_callback stop_requested_cb) const = 0;
[[nodiscard]] virtual auto get_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error = 0;
[[nodiscard]] virtual auto get_api_path_list() const
-> std::vector<std::string> = 0;
[[nodiscard]] virtual auto get_item_meta(const std::string &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,
std::string &value) const
-> api_error = 0;
[[nodiscard]] virtual auto get_pinned_files() const
-> std::vector<std::string> = 0;
[[nodiscard]] virtual auto get_total_item_count() const -> std::uint64_t = 0;
[[nodiscard]] virtual auto get_total_size() const -> std::uint64_t = 0;
virtual void remove_api_path(const std::string &api_path) = 0;
[[nodiscard]] virtual auto remove_item_meta(const std::string &api_path,
const std::string &key)
-> api_error = 0;
[[nodiscard]] virtual auto rename_item_meta(const std::string &from_api_path,
const std::string &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)
-> api_error = 0;
[[nodiscard]] virtual auto set_item_meta(const std::string &api_path,
const api_meta_map &meta)
-> api_error = 0;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_I_META_DB_HPP_

View File

@ -0,0 +1,121 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_IMPL_RDB_FILE_DB_HPP_
#define REPERTORY_INCLUDE_DB_IMPL_RDB_FILE_DB_HPP_
#include "db/i_file_db.hpp"
namespace repertory {
class app_config;
class rdb_file_db final : public i_file_db {
public:
rdb_file_db(const app_config &cfg);
~rdb_file_db() override;
rdb_file_db(const rdb_file_db &) = delete;
rdb_file_db(rdb_file_db &&) = delete;
auto operator=(const rdb_file_db &) -> rdb_file_db & = delete;
auto operator=(rdb_file_db &&) -> rdb_file_db & = delete;
private:
const app_config &cfg_;
private:
std::unique_ptr<rocksdb::TransactionDB> db_{nullptr};
rocksdb::ColumnFamilyHandle *directory_family_{};
rocksdb::ColumnFamilyHandle *file_family_{};
rocksdb::ColumnFamilyHandle *path_family_{};
rocksdb::ColumnFamilyHandle *source_family_{};
private:
void create_or_open(bool clear);
[[nodiscard]] auto create_iterator(rocksdb::ColumnFamilyHandle *family) const
-> std::shared_ptr<rocksdb::Iterator>;
[[nodiscard]] static auto
perform_action(std::string_view function_name,
std::function<rocksdb::Status()> action) -> api_error;
[[nodiscard]] auto perform_action(
std::string_view function_name,
std::function<rocksdb::Status(rocksdb::Transaction *txn)> action)
-> api_error;
[[nodiscard]] auto remove_item(const std::string &api_path,
const std::string &source_path,
rocksdb::Transaction *txn) -> rocksdb::Status;
public:
[[nodiscard]] auto add_directory(const std::string &api_path,
const std::string &source_path)
-> api_error override;
[[nodiscard]] auto add_or_update_file(const i_file_db::file_data &data)
-> api_error override;
void clear() override;
[[nodiscard]] auto count() const -> std::uint64_t override;
void enumerate_item_list(
std::function<void(const std::vector<i_file_db::file_info> &)> callback,
stop_type_callback stop_requested_cb) const override;
[[nodiscard]] auto get_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_directory_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_directory_source_path(const std::string &api_path,
std::string &source_path) const
-> api_error override;
[[nodiscard]] auto get_file_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_file_data(const std::string &api_path,
i_file_db::file_data &data) const
-> api_error override;
[[nodiscard]] auto get_file_source_path(const std::string &api_path,
std::string &source_path) const
-> api_error override;
[[nodiscard]] auto get_item_list(stop_type_callback stop_requested_cb) const
-> std::vector<i_file_db::file_info> override;
[[nodiscard]] auto get_source_path(const std::string &api_path,
std::string &source_path) const
-> api_error override;
[[nodiscard]] auto remove_item(const std::string &api_path)
-> api_error override;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_IMPL_RDB_FILE_DB_HPP_

View File

@ -0,0 +1,109 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_IMPL_RDB_FILE_MGR_DB_HPP_
#define REPERTORY_INCLUDE_DB_IMPL_RDB_FILE_MGR_DB_HPP_
#include "db/i_file_mgr_db.hpp"
namespace repertory {
class app_config;
class rdb_file_mgr_db final : public i_file_mgr_db {
public:
rdb_file_mgr_db(const app_config &cfg);
~rdb_file_mgr_db() override;
rdb_file_mgr_db(const rdb_file_mgr_db &) = delete;
rdb_file_mgr_db(rdb_file_mgr_db &&) = delete;
auto operator=(const rdb_file_mgr_db &) -> rdb_file_mgr_db & = delete;
auto operator=(rdb_file_mgr_db &&) -> rdb_file_mgr_db & = delete;
private:
const app_config &cfg_;
private:
std::unique_ptr<rocksdb::TransactionDB> db_{nullptr};
std::atomic<std::uint64_t> id_{0U};
rocksdb::ColumnFamilyHandle *resume_family_{};
rocksdb::ColumnFamilyHandle *upload_active_family_{};
rocksdb::ColumnFamilyHandle *upload_family_{};
private:
void create_or_open(bool clear);
[[nodiscard]] auto create_iterator(rocksdb::ColumnFamilyHandle *family) const
-> std::shared_ptr<rocksdb::Iterator>;
[[nodiscard]] static auto
perform_action(std::string_view function_name,
std::function<rocksdb::Status()> action) -> bool;
[[nodiscard]] auto perform_action(
std::string_view function_name,
std::function<rocksdb::Status(rocksdb::Transaction *txn)> action) -> bool;
[[nodiscard]] auto remove_resume(const std::string &api_path,
rocksdb::Transaction *txn)
-> rocksdb::Status;
[[nodiscard]] auto add_resume(const resume_entry &entry,
rocksdb::Transaction *txn) -> rocksdb::Status;
public:
[[nodiscard]] auto add_resume(const resume_entry &entry) -> bool override;
[[nodiscard]] auto add_upload(const upload_entry &entry) -> bool override;
[[nodiscard]] auto add_upload_active(const upload_active_entry &entry)
-> bool override;
void clear() override;
[[nodiscard]] auto get_next_upload() const
-> std::optional<upload_entry> override;
[[nodiscard]] auto get_resume_list() const
-> std::vector<resume_entry> override;
[[nodiscard]] auto get_upload(const std::string &api_path) const
-> std::optional<upload_entry> override;
[[nodiscard]] auto get_upload_active_list() const
-> std::vector<upload_active_entry> override;
[[nodiscard]] auto remove_resume(const std::string &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)
-> bool override;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_IMPL_RDB_FILE_MGR_DB_HPP_

View File

@ -0,0 +1,131 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_IMPL_RDB_META_DB_HPP_
#define REPERTORY_INCLUDE_DB_IMPL_RDB_META_DB_HPP_
#include "db/i_meta_db.hpp"
#include "types/repertory.hpp"
namespace repertory {
class app_config;
class rdb_meta_db final : public i_meta_db {
public:
rdb_meta_db(const app_config &cfg);
~rdb_meta_db() override;
rdb_meta_db(const rdb_meta_db &) = delete;
rdb_meta_db(rdb_meta_db &&) = delete;
auto operator=(const rdb_meta_db &) -> rdb_meta_db & = delete;
auto operator=(rdb_meta_db &&) -> rdb_meta_db & = delete;
private:
const app_config &cfg_;
private:
std::unique_ptr<rocksdb::TransactionDB> db_{nullptr};
rocksdb::ColumnFamilyHandle *meta_family_{};
rocksdb::ColumnFamilyHandle *pinned_family_{};
rocksdb::ColumnFamilyHandle *size_family_{};
rocksdb::ColumnFamilyHandle *source_family_{};
private:
[[nodiscard]] auto create_iterator(rocksdb::ColumnFamilyHandle *family) const
-> std::shared_ptr<rocksdb::Iterator>;
void create_or_open(bool clear);
[[nodiscard]] auto get_item_meta_json(const std::string &api_path,
json &json_data) const -> api_error;
[[nodiscard]] static auto
perform_action(std::string_view function_name,
std::function<rocksdb::Status()> action) -> api_error;
[[nodiscard]] auto perform_action(
std::string_view function_name,
std::function<rocksdb::Status(rocksdb::Transaction *txn)> action)
-> api_error;
[[nodiscard]] auto remove_api_path(const std::string &api_path,
const std::string &source_path,
rocksdb::Transaction *txn)
-> rocksdb::Status;
[[nodiscard]] auto update_item_meta(const std::string &api_path,
json json_data,
rocksdb::Transaction *base_txn = nullptr,
rocksdb::Status *status = nullptr)
-> api_error;
public:
void clear() override;
void enumerate_api_path_list(
std::function<void(const std::vector<std::string> &)> callback,
stop_type_callback stop_requested_cb) const override;
[[nodiscard]] auto get_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_api_path_list() const
-> std::vector<std::string> override;
[[nodiscard]] auto get_item_meta(const std::string &api_path,
api_meta_map &meta) const
-> api_error override;
[[nodiscard]] auto get_item_meta(const std::string &api_path,
const std::string &key,
std::string &value) const
-> api_error override;
[[nodiscard]] auto get_pinned_files() const
-> std::vector<std::string> override;
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override;
[[nodiscard]] auto get_total_size() const -> std::uint64_t override;
void remove_api_path(const std::string &api_path) override;
[[nodiscard]] auto remove_item_meta(const std::string &api_path,
const std::string &key)
-> api_error override;
[[nodiscard]] auto rename_item_meta(const std::string &from_api_path,
const std::string &to_api_path)
-> api_error override;
[[nodiscard]] auto set_item_meta(const std::string &api_path,
const std::string &key,
const std::string &value)
-> api_error override;
[[nodiscard]] auto set_item_meta(const std::string &api_path,
const api_meta_map &meta)
-> api_error override;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_IMPL_RDB_META_DB_HPP_

View File

@ -0,0 +1,96 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_IMPL_SQLITE_FILE_DB_HPP_
#define REPERTORY_INCLUDE_DB_IMPL_SQLITE_FILE_DB_HPP_
#include "db/i_file_db.hpp"
#include "utils/db/sqlite/db_common.hpp"
namespace repertory {
class app_config;
class sqlite_file_db final : public i_file_db {
public:
sqlite_file_db(const app_config &cfg);
~sqlite_file_db() override;
sqlite_file_db(const sqlite_file_db &) = delete;
sqlite_file_db(sqlite_file_db &&) = delete;
auto operator=(const sqlite_file_db &) -> sqlite_file_db & = delete;
auto operator=(sqlite_file_db &&) -> sqlite_file_db & = delete;
private:
utils::db::sqlite::db3_t db_;
public:
[[nodiscard]] auto add_directory(const std::string &api_path,
const std::string &source_path)
-> api_error override;
[[nodiscard]] auto add_or_update_file(const i_file_db::file_data &data)
-> api_error override;
void clear() override;
[[nodiscard]] auto count() const -> std::uint64_t override;
void enumerate_item_list(
std::function<void(const std::vector<i_file_db::file_info> &)> callback,
stop_type_callback stop_requested_cb) const override;
[[nodiscard]] auto get_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_directory_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_directory_source_path(const std::string &api_path,
std::string &source_path) const
-> api_error override;
[[nodiscard]] auto get_file_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_file_data(const std::string &api_path,
i_file_db::file_data &data) const
-> api_error override;
[[nodiscard]] auto get_file_source_path(const std::string &api_path,
std::string &source_path) const
-> api_error override;
[[nodiscard]] auto get_item_list(stop_type_callback stop_requested_cb) const
-> std::vector<i_file_db::file_info> override;
[[nodiscard]] auto get_source_path(const std::string &api_path,
std::string &source_path) const
-> api_error override;
[[nodiscard]] auto remove_item(const std::string &api_path)
-> api_error override;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_IMPL_SQLITE_FILE_DB_HPP_

View File

@ -0,0 +1,82 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_IMPL_SQLITE_FILE_MGR_DB_HPP_
#define REPERTORY_INCLUDE_DB_IMPL_SQLITE_FILE_MGR_DB_HPP_
#include "db/i_file_mgr_db.hpp"
#include "utils/db/sqlite/db_common.hpp"
namespace repertory {
class app_config;
class sqlite_file_mgr_db final : public i_file_mgr_db {
public:
sqlite_file_mgr_db(const app_config &cfg);
~sqlite_file_mgr_db() override;
sqlite_file_mgr_db(const sqlite_file_mgr_db &) = delete;
sqlite_file_mgr_db(sqlite_file_mgr_db &&) = delete;
auto operator=(const sqlite_file_mgr_db &) -> sqlite_file_mgr_db & = delete;
auto operator=(sqlite_file_mgr_db &&) -> sqlite_file_mgr_db & = delete;
private:
utils::db::sqlite::db3_t db_;
public:
[[nodiscard]] auto add_resume(const resume_entry &entry) -> bool override;
[[nodiscard]] auto add_upload(const upload_entry &entry) -> bool override;
[[nodiscard]] auto add_upload_active(const upload_active_entry &entry)
-> bool override;
void clear() override;
[[nodiscard]] auto get_next_upload() const
-> std::optional<upload_entry> override;
[[nodiscard]] auto get_resume_list() const
-> std::vector<resume_entry> override;
[[nodiscard]] auto get_upload(const std::string &api_path) const
-> std::optional<upload_entry> override;
[[nodiscard]] auto get_upload_active_list() const
-> std::vector<upload_active_entry> override;
[[nodiscard]] auto remove_resume(const std::string &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)
-> bool override;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_IMPL_SQLITE_FILE_MGR_DB_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,27 +19,28 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_PROVIDERS_META_DB_HPP_
#define INCLUDE_PROVIDERS_META_DB_HPP_
#ifndef REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
#define REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
#include "database/db_common.hpp"
#include "db/i_meta_db.hpp"
#include "types/repertory.hpp"
#include "utils/db/sqlite/db_common.hpp"
namespace repertory {
class app_config;
class meta_db final {
class sqlite_meta_db final : public i_meta_db {
public:
meta_db(const app_config &cfg);
~meta_db();
sqlite_meta_db(const app_config &cfg);
~sqlite_meta_db() override;
meta_db(const meta_db &) = delete;
meta_db(meta_db &&) = delete;
auto operator=(const meta_db &) -> meta_db & = delete;
auto operator=(meta_db &&) -> meta_db & = delete;
sqlite_meta_db(const sqlite_meta_db &) = delete;
sqlite_meta_db(sqlite_meta_db &&) = delete;
auto operator=(const sqlite_meta_db &) -> sqlite_meta_db & = delete;
auto operator=(sqlite_meta_db &&) -> sqlite_meta_db & = delete;
private:
db::db3_t db_;
utils::db::sqlite::db3_t db_;
constexpr static const auto table_name = "meta";
private:
@ -47,38 +48,54 @@ private:
api_meta_map meta) -> api_error;
public:
[[nodiscard]] auto get_api_path(const std::string &source_path,
std::string &api_path) -> api_error;
void clear() override;
[[nodiscard]] auto get_api_path_list() -> std::vector<std::string>;
void enumerate_api_path_list(
std::function<void(const std::vector<std::string> &)> callback,
stop_type_callback stop_requested_cb) const override;
[[nodiscard]] auto get_api_path(const std::string &source_path,
std::string &api_path) const
-> api_error override;
[[nodiscard]] auto get_api_path_list() const
-> std::vector<std::string> override;
[[nodiscard]] auto get_item_meta(const std::string &api_path,
api_meta_map &meta) -> api_error;
api_meta_map &meta) const
-> api_error override;
[[nodiscard]] auto get_item_meta(const std::string &api_path,
const std::string &key,
std::string &value) const -> api_error;
std::string &value) const
-> api_error override;
[[nodiscard]] auto get_pinned_files() const -> std::vector<std::string>;
[[nodiscard]] auto get_pinned_files() const
-> std::vector<std::string> override;
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t;
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override;
void remove_api_path(const std::string &api_path);
[[nodiscard]] auto get_total_size() const -> std::uint64_t override;
void remove_api_path(const std::string &api_path) override;
[[nodiscard]] auto remove_item_meta(const std::string &api_path,
const std::string &key) -> api_error;
const std::string &key)
-> api_error override;
[[nodiscard]] auto rename_item_meta(const std::string &from_api_path,
const std::string &to_api_path)
-> api_error;
-> api_error override;
[[nodiscard]] auto set_item_meta(const std::string &api_path,
const std::string &key,
const std::string &value) -> api_error;
const std::string &value)
-> api_error override;
[[nodiscard]] auto set_item_meta(const std::string &api_path,
const api_meta_map &meta) -> api_error;
const api_meta_map &meta)
-> api_error override;
};
} // namespace repertory
#endif // INCLUDE_PROVIDERS_META_DB_HPP_
#endif // REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_

View File

@ -0,0 +1,34 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_DB_META_DB_HPP_
#define REPERTORY_INCLUDE_DB_META_DB_HPP_
#include "db/i_meta_db.hpp"
namespace repertory {
class app_config;
[[nodiscard]] auto create_meta_db(const app_config &cfg)
-> std::unique_ptr<i_meta_db>;
} // namespace repertory
#endif // REPERTORY_INCLUDE_DB_META_DB_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,30 +19,25 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
#define INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
#include "utils/single_thread_service_base.hpp"
#include <memory>
#ifndef REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
#define REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
namespace repertory {
class directory_iterator;
class directory_cache final : public single_thread_service_base {
class directory_cache final {
public:
using execute_callback = std::function<void(directory_iterator &)>;
private:
struct open_directory final {
std::shared_ptr<directory_iterator> iterator;
std::vector<std::uint64_t> handles{};
std::chrono::system_clock::time_point last_update{
std::chrono::system_clock::now()};
std::vector<std::uint64_t> handles;
};
public:
directory_cache() : single_thread_service_base("directory_cache") {}
~directory_cache() override = default;
directory_cache() = default;
~directory_cache() = default;
directory_cache(const directory_cache &) = delete;
directory_cache(directory_cache &&) = delete;
@ -52,19 +47,15 @@ public:
private:
std::unordered_map<std::string, open_directory> directory_lookup_;
std::recursive_mutex directory_mutex_;
std::unique_ptr<std::thread> refresh_thread_;
protected:
void service_function() override;
public:
void execute_action(const std::string &api_path,
const execute_callback &execute);
[[nodiscard]] auto
get_directory(std::uint64_t handle) -> std::shared_ptr<directory_iterator>;
[[nodiscard]] auto get_directory(std::uint64_t handle)
-> std::shared_ptr<directory_iterator>;
[[nodiscard]] auto remove_directory(const std::string &api_path)
auto remove_directory(const std::string &api_path)
-> std::shared_ptr<directory_iterator>;
void remove_directory(std::uint64_t handle);
@ -74,4 +65,4 @@ public:
};
} // namespace repertory
#endif // INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
#define INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
#define REPERTORY_INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
#include "types/remote.hpp"
#include "types/repertory.hpp"
@ -78,4 +78,4 @@ public:
};
} // namespace repertory
#endif // INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_EVICTION_HPP_
#define INCLUDE_DRIVES_EVICTION_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_EVICTION_HPP_
#define REPERTORY_INCLUDE_DRIVES_EVICTION_HPP_
#include "utils/single_thread_service_base.hpp"
@ -31,18 +31,19 @@ class i_provider;
class eviction final : public single_thread_service_base {
public:
eviction(i_provider &provider, const app_config &config, i_file_manager &fm)
eviction(i_provider &provider, const app_config &config,
i_file_manager &file_mgr)
: single_thread_service_base("eviction"),
provider_(provider),
config_(config),
fm_(fm) {}
file_mgr_(file_mgr),
provider_(provider) {}
~eviction() override = default;
private:
i_provider &provider_;
const app_config &config_;
i_file_manager &fm_;
i_file_manager &file_mgr_;
i_provider &provider_;
private:
[[nodiscard]] auto check_minimum_requirements(const std::string &file_path)
@ -55,4 +56,4 @@ protected:
};
} // namespace repertory
#endif // INCLUDE_DRIVES_EVICTION_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_EVICTION_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,12 +19,12 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
#define INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
#if !defined(_WIN32)
#include "events/event_system.hpp"
#include "utils/path.hpp"
#include "types/repertory.hpp"
namespace repertory {
class app_config;
@ -51,8 +51,8 @@ private:
std::string mount_location_;
protected:
bool atime_enabled_ = true;
bool console_enabled_ = false;
bool atime_enabled_{true};
bool console_enabled_{false};
std::optional<gid_t> forced_gid_;
std::optional<uid_t> forced_uid_;
std::optional<mode_t> forced_umask_;
@ -604,4 +604,4 @@ public:
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
#define INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
#if !defined(_WIN32)
#include "drives/fuse/fuse_drive_base.hpp"
@ -63,11 +63,14 @@ private:
std::shared_ptr<logging_consumer> logging_consumer_;
std::shared_ptr<remote_fuse::remote_server> remote_server_;
std::shared_ptr<full_server> server_;
bool was_mounted_ = false;
std::mutex stop_all_mtx_;
bool was_mounted_{false};
private:
void update_accessed_time(const std::string &api_path);
void stop_all();
protected:
#if defined(__APPLE__)
[[nodiscard]] auto chflags_impl(std::string api_path,
@ -103,7 +106,7 @@ protected:
struct fuse_file_info *file_info) -> api_error override;
[[nodiscard]] auto
fgetattr_impl(std::string api_path, struct stat *st,
fgetattr_impl(std::string api_path, struct stat *unix_st,
struct fuse_file_info *file_info) -> api_error override;
#if defined(__APPLE__)
@ -124,11 +127,11 @@ protected:
#if FUSE_USE_VERSION >= 30
[[nodiscard]] auto
getattr_impl(std::string api_path, struct stat *st,
getattr_impl(std::string api_path, struct stat *unix_st,
struct fuse_file_info *file_info) -> api_error override;
#else
[[nodiscard]] auto getattr_impl(std::string api_path,
struct stat *st) -> api_error override;
struct stat *unix_st) -> api_error override;
#endif
#if defined(__APPLE__)
@ -323,4 +326,4 @@ public:
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
#define INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
#if !defined(_WIN32)
#include "drives/fuse/fuse_base.hpp"
@ -134,4 +134,4 @@ public:
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
#define INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
#if !defined(_WIN32)
#include "types/repertory.hpp"
@ -81,4 +81,4 @@ public:
} // namespace repertory
#endif
#endif // INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
#include "drives/remote/i_remote_json.hpp"
#include "types/remote.hpp"
@ -30,26 +30,25 @@ 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,
const 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_chflags(const char *path, std::uint32_t flags) -> 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_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_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;
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,
@ -61,24 +60,21 @@ public:
fuse_fgetattr(const char *path, remote::stat &r_stat, bool &directory,
const 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,
const 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, const std::int32_t &datasync,
const 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, const remote::file_offset &size,
const 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;
@ -87,10 +83,9 @@ public:
const char *name, char *value, const 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;
@ -98,65 +93,63 @@ public:
char *buffer, const 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,
const 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_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_opendir(const char *path,
remote::file_handle &handle) -> packet::error_type = 0;
[[nodiscard]] virtual auto fuse_read(const char *path, char *buffer,
const remote::file_size &read_size,
[[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;
const 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;
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_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,
const 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,
const 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,
const 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,
const 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
@ -165,36 +158,35 @@ public:
const char *name, const char *value, const 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,
const remote::file_offset &size)
-> packet::error_type = 0;
[[nodiscard]] virtual auto
fuse_truncate(const char *path,
const remote::file_offset &size) -> packet::error_type = 0;
[[nodiscard]] virtual auto fuse_unlink(const char *path)
-> 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_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,
[[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;
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;
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;
@ -204,4 +196,4 @@ using remote_instance_factory =
std::function<std::unique_ptr<i_remote_instance>()>;
} // namespace repertory::remote_fuse
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
#include "comm/packet/packet_client.hpp"
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
@ -51,9 +51,9 @@ public:
[[nodiscard]] auto fuse_chmod(const char *path, const 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)
-> packet::error_type override;
[[nodiscard]] auto
fuse_chown(const char *path, const remote::user_id &uid,
const remote::group_id &gid) -> packet::error_type override;
[[nodiscard]] auto fuse_destroy() -> packet::error_type override;
@ -67,23 +67,21 @@ public:
const 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)
-> packet::error_type override;
[[nodiscard]] auto fuse_fsetattr_x(
const char *path, const remote::setattr_x &attr,
const 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)
-> packet::error_type override;
[[nodiscard]] auto
fuse_fsync(const char *path, const std::int32_t &datasync,
const 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)
-> packet::error_type override;
[[nodiscard]] auto fuse_ftruncate(
const char *path, const remote::file_offset &size,
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_getattr(const char *path, remote::stat &st,
bool &directory)
-> packet::error_type override;
[[nodiscard]] auto
fuse_getattr(const char *path, remote::stat &st,
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 ;
@ -92,10 +90,9 @@ public:
*name, char *value, const remote::file_size &size, std::uint32_t position)
override ;*/
[[nodiscard]] auto fuse_getxtimes(const char *path,
remote::file_time &bkuptime,
remote::file_time &crtime)
-> packet::error_type override;
[[nodiscard]] auto
fuse_getxtimes(const char *path, remote::file_time &bkuptime,
remote::file_time &crtime) -> packet::error_type override;
[[nodiscard]] auto fuse_init() -> packet::error_type override;
@ -110,27 +107,25 @@ public:
[[nodiscard]] auto
fuse_create(const char *path, const remote::file_mode &mode,
const remote::open_flags &flags, remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_open(const char *path,
const remote::open_flags &flags,
remote::file_handle &handle)
-> packet::error_type override;
remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_read(const char *path, char *buffer,
const remote::file_size &read_size,
[[nodiscard]] auto
fuse_open(const char *path, const remote::open_flags &flags,
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)
-> packet::error_type override;
const 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_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)
-> packet::error_type override;
const remote::file_handle &handle,
std::string &item_path) -> packet::error_type override;
[[nodiscard]] auto fuse_release(const char *path,
const remote::file_handle &handle)
@ -144,8 +139,8 @@ public:
* char *name) override
* ;*/
[[nodiscard]] auto fuse_rmdir(const char *path)
-> packet::error_type override;
[[nodiscard]] auto
fuse_rmdir(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_setattr_x(const char *path, remote::setattr_x &attr)
-> packet::error_type override;
@ -162,8 +157,8 @@ public:
const remote::file_time &crtime)
-> packet::error_type override;
[[nodiscard]] auto fuse_setvolname(const char *volname)
-> 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
@ -174,48 +169,45 @@ public:
std::int32_t &flags, std::uint32_t position) override ;*/
[[nodiscard]] auto
fuse_statfs(const char *path, std::uint64_t frsize, remote::statfs &st)
-> packet::error_type override;
fuse_statfs(const char *path, std::uint64_t frsize,
remote::statfs &st) -> packet::error_type override;
[[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize,
remote::statfs_x &st)
-> packet::error_type override;
[[nodiscard]] auto
fuse_statfs_x(const char *path, std::uint64_t bsize,
remote::statfs_x &st) -> packet::error_type override;
[[nodiscard]] auto fuse_truncate(const char *path,
const remote::file_offset &size)
-> packet::error_type override;
[[nodiscard]] auto
fuse_truncate(const char *path,
const remote::file_offset &size) -> packet::error_type override;
[[nodiscard]] auto fuse_unlink(const char *path)
-> packet::error_type override;
[[nodiscard]] auto
fuse_unlink(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0, std::uint64_t op1)
-> packet::error_type override;
[[nodiscard]] auto
fuse_utimens(const char *path, const remote::file_time *tv, std::uint64_t op0,
std::uint64_t op1) -> packet::error_type override;
[[nodiscard]] auto fuse_write(const char *path, const char *buffer,
[[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)
-> packet::error_type override;
const 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,
[[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)
-> packet::error_type override;
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto json_create_directory_snapshot(const std::string &path,
json &json_data)
-> packet::error_type override;
[[nodiscard]] auto json_create_directory_snapshot(
const std::string &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)
-> packet::error_type override;
[[nodiscard]] auto json_release_directory_snapshot(
const std::string &path,
const remote::file_handle &handle) -> packet::error_type override;
void set_fuse_uid_gid(const remote::user_id &uid,
const remote::group_id &gid) override;
@ -223,4 +215,4 @@ public:
} // namespace remote_fuse
} // namespace repertory
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
#if !defined(_WIN32)
#include "drives/fuse/fuse_base.hpp"
@ -53,7 +53,7 @@ private:
bool was_mounted_ = false;
private:
void populate_stat(const remote::stat &r_stat, bool directory,
static void populate_stat(const remote::stat &r_stat, bool directory,
struct stat &unix_st);
protected:
@ -238,4 +238,4 @@ protected:
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
#if !defined(_WIN32)
#include "drives/directory_cache.hpp"
@ -49,9 +49,9 @@ private:
[[nodiscard]] auto get_next_handle() -> std::uint64_t;
[[nodiscard]] auto
populate_file_info(const std::string &api_path,
remote::file_info &file_info) -> packet::error_type;
[[nodiscard]] auto populate_file_info(const std::string &api_path,
remote::file_info &file_info)
-> packet::error_type;
void populate_file_info(const std::string &api_path, const UINT64 &file_size,
const UINT32 &attributes,
@ -72,14 +72,14 @@ public:
[[nodiscard]] auto fuse_chmod(const char *path, const 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) -> packet::error_type override;
[[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid,
const 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) -> packet::error_type override;
const remote::open_flags &flags, remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_destroy() -> packet::error_type override;
@ -88,25 +88,28 @@ public:
remote::file_offset &length, const remote::file_handle &handle) override
;*/
[[nodiscard]] auto fuse_fgetattr(
const char *path, remote::stat &r_stat, bool &directory,
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_fgetattr(const char *path, remote::stat &r_stat,
bool &directory,
const 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) -> packet::error_type override;
[[nodiscard]] auto fuse_fsetattr_x(const char *path,
const remote::setattr_x &attr,
const 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) -> packet::error_type override;
[[nodiscard]] auto fuse_fsync(const char *path, const std::int32_t &datasync,
const 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) -> packet::error_type override;
[[nodiscard]] auto fuse_ftruncate(const char *path,
const remote::file_offset &size,
const remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto
fuse_getattr(const char *path, remote::stat &r_stat,
bool &directory) -> packet::error_type override;
[[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 ;
@ -115,9 +118,10 @@ public:
*name, char *value, const remote::file_size &size, std::uint32_t position)
override ;*/
[[nodiscard]] auto
fuse_getxtimes(const char *path, remote::file_time &bkuptime,
remote::file_time &crtime) -> packet::error_type override;
[[nodiscard]] auto fuse_getxtimes(const char *path,
remote::file_time &bkuptime,
remote::file_time &crtime)
-> packet::error_type override;
[[nodiscard]] auto fuse_init() -> packet::error_type override;
@ -125,28 +129,30 @@ public:
*buffer, const remote::file_size &size) override ;*/
[[nodiscard]] auto
fuse_mkdir(const char *path,
const remote::file_mode &mode) -> packet::error_type override;
fuse_mkdir(const char *path, const remote::file_mode &mode)
-> packet::error_type override;
[[nodiscard]] auto
fuse_open(const char *path, const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_open(const char *path,
const remote::open_flags &flags,
remote::file_handle &handle)
-> packet::error_type override;
[[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,
[[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) -> packet::error_type override;
const 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_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) -> packet::error_type override;
const remote::file_handle &handle, std::string &item_path)
-> packet::error_type override;
[[nodiscard]] auto fuse_release(const char *path,
const remote::file_handle &handle)
@ -160,8 +166,8 @@ public:
* char *name) override
* ;*/
[[nodiscard]] auto
fuse_rmdir(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_rmdir(const char *path)
-> packet::error_type override;
[[nodiscard]] auto fuse_setattr_x(const char *path, remote::setattr_x &attr)
-> packet::error_type override;
@ -178,8 +184,8 @@ public:
const remote::file_time &crtime)
-> packet::error_type override;
[[nodiscard]] auto
fuse_setvolname(const char *volname) -> 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
@ -189,67 +195,70 @@ public:
char *name, const char *value, const 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 &r_stat) -> packet::error_type override;
[[nodiscard]] auto 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 &r_stat) -> packet::error_type override;
[[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize,
remote::statfs_x &r_stat)
-> packet::error_type override;
[[nodiscard]] auto
fuse_truncate(const char *path,
const remote::file_offset &size) -> packet::error_type override;
[[nodiscard]] auto fuse_truncate(const char *path,
const remote::file_offset &size)
-> packet::error_type override;
[[nodiscard]] auto
fuse_unlink(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_unlink(const char *path)
-> packet::error_type override;
[[nodiscard]] auto
fuse_utimens(const char *path, const remote::file_time *tv, std::uint64_t op0,
std::uint64_t op1) -> packet::error_type override;
[[nodiscard]] auto fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0, std::uint64_t op1)
-> packet::error_type override;
[[nodiscard]] auto
fuse_write(const char *path, const char *buffer,
[[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) -> packet::error_type override;
const 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,
[[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) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
void set_fuse_uid_gid(const remote::user_id &,
const remote::group_id &) override {}
// JSON Layer
[[nodiscard]] auto
winfsp_get_dir_buffer(PVOID /*file_desc*/,
PVOID *& /*ptr*/) -> packet::error_type override {
[[nodiscard]] auto winfsp_get_dir_buffer(PVOID /*file_desc*/,
PVOID *& /*ptr*/)
-> packet::error_type override {
return static_cast<packet::error_type>(STATUS_INVALID_HANDLE);
}
[[nodiscard]] auto json_create_directory_snapshot(
const std::string &path, json &json_data) -> packet::error_type override;
[[nodiscard]] auto json_create_directory_snapshot(const std::string &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) -> packet::error_type override;
[[nodiscard]] auto
json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle)
-> packet::error_type override;
// WinFSP Layer
[[nodiscard]] auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override;
[[nodiscard]] auto winfsp_cleanup(PVOID file_desc, PWSTR file_name,
UINT32 flags, BOOLEAN &was_deleted)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_close(PVOID file_desc) -> packet::error_type override;
[[nodiscard]] auto winfsp_close(PVOID file_desc)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
@ -264,60 +273,66 @@ public:
remote::file_info *file_info)
-> packet::error_type override;
[[nodiscard]] auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 attributes,
[[nodiscard]] auto
winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes,
std::uint64_t * /*security_descriptor_size*/,
std::wstring & /*str_descriptor*/) -> packet::error_type override;
std::wstring & /*str_descriptor*/)
-> packet::error_type override;
[[nodiscard]] auto winfsp_get_volume_info(
UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) -> packet::error_type override;
[[nodiscard]] auto winfsp_get_volume_info(UINT64 &total_size,
UINT64 &free_size,
std::string &volume_label)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_mounted(const std::wstring &location) -> packet::error_type override;
[[nodiscard]] auto winfsp_mounted(const std::wstring &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,
std::string &normalized_name) -> 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,
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) -> packet::error_type override;
[[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes,
UINT64 /*allocation_size*/,
remote::file_info *file_info)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override;
[[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
UINT32 length, PUINT32 bytes_transferred)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, PWSTR marker,
json &itemList) -> packet::error_type override;
[[nodiscard]] auto winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
PWSTR marker, json &itemList)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override;
[[nodiscard]] auto winfsp_rename(PVOID /*file_desc*/, PWSTR file_name,
PWSTR new_file_name,
BOOLEAN replace_if_exists)
-> packet::error_type override;
[[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;
[[nodiscard]] auto winfsp_set_file_size(
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_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)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
[[nodiscard]] auto winfsp_unmounted(const std::wstring &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) -> packet::error_type override;
PUINT32 bytes_transferred, remote::file_info *file_info)
-> packet::error_type override;
};
} // namespace remote_fuse
} // namespace repertory
#endif
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
#define INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
#define REPERTORY_INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
#include "comm/packet/packet.hpp"
@ -30,18 +30,17 @@ 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(const std::string &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_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle)
-> packet::error_type = 0;
[[nodiscard]] virtual auto json_release_directory_snapshot(
const std::string &path,
const remote::file_handle &handle) -> packet::error_type = 0;
};
} // namespace repertory
#endif // INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
#define INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
#define REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
#include "types/remote.hpp"
#include "types/repertory.hpp"
@ -33,25 +33,32 @@ protected:
virtual ~remote_open_file_table() = default;
protected:
struct compat_open_info {
std::size_t count = 0u;
std::string client_id = "";
struct compat_open_info final {
std::string client_id;
std::vector<remote::file_handle> handles;
std::string path;
};
struct open_info {
std::size_t count = 0u;
std::string client_id = "";
PVOID directory_buffer = nullptr;
struct open_info final {
std::string client_id;
PVOID directory_buffer{nullptr};
std::vector<native_handle> handles;
std::string path;
};
private:
std::unordered_map<remote::file_handle, compat_open_info> compat_lookup_;
std::recursive_mutex compat_mutex_;
std::unordered_map<std::string, std::unique_ptr<compat_open_info>>
compat_file_lookup_;
std::unordered_map<remote::file_handle, std::string> compat_handle_lookup_;
private:
std::unordered_map<std::string, std::vector<std::uint64_t>> directory_lookup_;
std::recursive_mutex directory_mutex_;
std::unordered_map<native_handle, open_info> file_lookup_;
private:
std::unordered_map<std::string, std::unique_ptr<open_info>> file_lookup_;
std::unordered_map<native_handle, std::string> handle_lookup_;
private:
mutable std::recursive_mutex file_mutex_;
protected:
@ -64,11 +71,11 @@ protected:
PVOID *&buffer) -> bool;
#endif // _WIN32
[[nodiscard]] auto
get_open_file_path(const native_handle &handle) -> std::string;
[[nodiscard]] auto get_open_file_path(const native_handle &handle)
-> std::string;
[[nodiscard]] auto get_open_info(const native_handle &handle,
open_info &oi) -> bool;
[[nodiscard]] auto get_open_info(const native_handle &handle, open_info &oi)
-> bool;
[[nodiscard]] auto has_open_directory(const std::string &client_id,
std::uint64_t handle) -> bool;
@ -77,20 +84,21 @@ protected:
int error_return) -> int;
template <typename error_type>
[[nodiscard]] auto
has_open_info(const native_handle &handle,
const error_type &error_return) -> error_type {
[[nodiscard]] auto has_open_info(const native_handle &handle,
const error_type &error_return)
-> error_type {
recur_mutex_lock file_lock(file_mutex_);
return ((file_lookup_.find(handle) == file_lookup_.end()) ? error_return
: 0);
return handle_lookup_.contains(handle) ? 0 : error_return;
}
void remove_all(const std::string &file_path);
void remove_and_close_all(const native_handle &handle);
void remove_compat_open_info(const remote::file_handle &handle);
auto remove_directory(const std::string &client_id,
std::uint64_t handle) -> bool;
auto remove_directory(const std::string &client_id, std::uint64_t handle)
-> bool;
void remove_open_info(const native_handle &handle);
@ -102,12 +110,12 @@ protected:
void set_compat_open_info(const remote::file_handle &handle,
const std::string &file_path);
void set_open_info(const native_handle &handle, open_info oi);
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 -> std::size_t;
[[nodiscard]] auto get_open_file_count(const std::string &file_path) const
-> std::size_t;
};
} // namespace repertory
#endif // INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
#define INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
#define REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
#include "app_config.hpp"
#include "comm/packet/client_pool.hpp"
@ -29,6 +29,11 @@
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
#include "drives/remote/remote_open_file_table.hpp"
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
#include "events/event_system.hpp"
#include "events/types/service_start_begin.hpp"
#include "events/types/service_start_end.hpp"
#include "events/types/service_stop_begin.hpp"
#include "events/types/service_stop_end.hpp"
#include "types/remote.hpp"
#include "types/repertory.hpp"
#include "utils/base64.hpp"
@ -52,8 +57,11 @@ public:
: config_(config),
drive_(drv),
mount_location_(std::move(mount_location)),
client_pool_(config.get_remote_client_pool_size()) {
event_system::instance().raise<service_started>("remote_server_base");
client_pool_(config.get_remote_mount().client_pool_size) {
REPERTORY_USES_FUNCTION_NAME();
event_system::instance().raise<service_start_begin>(function_name,
"remote_server_base");
handler_lookup_.insert(
{"::winfsp_can_delete",
[this](std::uint32_t, const std::string &, std::uint64_t,
@ -85,10 +93,10 @@ public:
UINT32 flags{};
DECODE_OR_RETURN(request, flags);
BOOLEAN was_closed{};
BOOLEAN was_deleted{};
ret = this->winfsp_cleanup(file_desc, file_name.data(), flags,
was_closed);
response.encode(was_closed);
was_deleted);
response.encode(was_deleted);
return ret;
}});
@ -137,12 +145,12 @@ public:
if (ret == STATUS_SUCCESS) {
#if defined(_WIN32)
this->set_client_id(file_desc, client_id);
#else
#else // !defined(_WIN32)
this->set_client_id(
static_cast<native_handle>(
reinterpret_cast<std::uintptr_t>(file_desc)),
client_id);
#endif
#endif // defined(_WIN32)
response.encode(file_desc);
response.encode(file_info);
response.encode(normalized_name);
@ -277,12 +285,12 @@ public:
if (ret == STATUS_SUCCESS) {
#if defined(_WIN32)
this->set_client_id(file_desc, client_id);
#else
#else // !defined(_WIN32)
this->set_client_id(
static_cast<native_handle>(
reinterpret_cast<std::uintptr_t>(file_desc)),
client_id);
#endif
#endif // defined(_WIN32)
response.encode(file_desc);
response.encode(file_info);
response.encode(normalized_name);
@ -585,9 +593,9 @@ public:
0) {
#if defined(_WIN32)
this->set_compat_client_id(handle, client_id);
#else
#else // !defined(_WIN32)
this->set_client_id(static_cast<native_handle>(handle), client_id);
#endif
#endif // defined(_WIN32)
response.encode(handle);
}
return ret;
@ -841,9 +849,9 @@ public:
if ((ret = this->fuse_open(path.c_str(), flags, handle)) >= 0) {
#if defined(_WIN32)
this->set_compat_client_id(handle, client_id);
#else
#else // !defined(_WIN32)
this->set_client_id(static_cast<native_handle>(handle), client_id);
#endif
#endif // defined(_WIN32)
response.encode(handle);
}
return ret;
@ -1357,7 +1365,8 @@ public:
}});
packet_server_ = std::make_unique<packet_server>(
config_.get_remote_port(), config_.get_remote_token(), 10,
config_.get_remote_mount().api_port,
config_.get_remote_mount().encryption_token, 10,
[this](const std::string &client_id) {
return this->closed_handler(client_id);
},
@ -1369,14 +1378,19 @@ public:
method, request, response,
message_complete);
});
event_system::instance().raise<service_start_end>(function_name,
"remote_server_base");
}
~remote_server_base() override {
event_system::instance().raise<service_shutdown_begin>(
REPERTORY_USES_FUNCTION_NAME();
event_system::instance().raise<service_stop_begin>(function_name,
"remote_server_base");
client_pool_.shutdown();
packet_server_.reset();
event_system::instance().raise<service_shutdown_end>("remote_server_base");
event_system::instance().raise<service_stop_end>(function_name,
"remote_server_base");
}
public:
@ -1430,4 +1444,4 @@ protected:
};
} // namespace repertory
#endif // INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
#define INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
#define REPERTORY_INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
#if defined(_WIN32)
#include "types/remote.hpp"
@ -31,22 +31,25 @@ class i_winfsp_drive {
INTERFACE_SETUP(i_winfsp_drive);
public:
[[nodiscard]] virtual auto get_directory_item_count(
const std::string &api_path) const -> std::uint64_t = 0;
[[nodiscard]] virtual auto get_directory_items(
const std::string &api_path) const -> directory_item_list = 0;
[[nodiscard]] virtual auto
get_directory_item_count(const std::string &api_path) const
-> std::uint64_t = 0;
[[nodiscard]] virtual auto
get_file_size(const std::string &api_path) const -> std::uint64_t = 0;
get_directory_items(const std::string &api_path) const
-> directory_item_list = 0;
[[nodiscard]] virtual auto
get_item_meta(const std::string &api_path, const std::string &name,
std::string &value) const -> api_error = 0;
[[nodiscard]] virtual auto get_file_size(const std::string &api_path) const
-> std::uint64_t = 0;
[[nodiscard]] virtual auto
get_item_meta(const std::string &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,
std::string &value) const
-> api_error = 0;
[[nodiscard]] virtual auto get_item_meta(const std::string &api_path,
api_meta_map &meta) const
-> api_error = 0;
[[nodiscard]] virtual auto
get_security_by_name(PWSTR file_name, PUINT32 attributes,
@ -62,11 +65,11 @@ 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) -> api_error = 0;
[[nodiscard]] virtual auto populate_file_info(const std::string &api_path,
remote::file_info &fi) const
-> api_error = 0;
};
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
#include "drives/remote/i_remote_json.hpp"
@ -33,7 +33,7 @@ public:
-> packet::error_type = 0;
virtual auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type = 0;
BOOLEAN &was_deleted) -> packet::error_type = 0;
virtual auto winfsp_close(PVOID file_desc) -> packet::error_type = 0;
@ -50,7 +50,8 @@ public:
virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type = 0;
virtual auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info)
virtual auto winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info)
-> packet::error_type = 0;
virtual auto
@ -86,11 +87,13 @@ public:
PWSTR marker, json &itemList)
-> packet::error_type = 0;
virtual auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type = 0;
virtual auto winfsp_rename(PVOID file_desc, PWSTR file_name,
PWSTR new_file_name, BOOLEAN replace_if_exists)
-> packet::error_type = 0;
virtual auto winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes,
UINT64 creation_time, UINT64 last_access_time,
UINT64 creation_time,
UINT64 last_access_time,
UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info)
-> packet::error_type = 0;
@ -114,4 +117,4 @@ using remote_instance_factory =
std::function<std::unique_ptr<i_remote_instance>()>;
} // namespace repertory::remote_winfsp
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,13 +19,14 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
#include "comm/packet/packet.hpp"
#include "comm/packet/packet_client.hpp"
#include "drives/remote/remote_open_file_table.hpp"
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
#include "types/remote.hpp"
namespace repertory {
class app_config;
@ -50,19 +51,20 @@ public:
auto json_create_directory_snapshot(const std::string &path, json &json_data)
-> packet::error_type override;
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;
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;
auto json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle)
-> packet::error_type override;
auto winfsp_can_delete(PVOID file_desc,
PWSTR file_name) -> packet::error_type override;
auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type override;
auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override;
BOOLEAN &was_deleted) -> packet::error_type override;
auto winfsp_close(PVOID file_desc) -> packet::error_type override;
@ -75,32 +77,33 @@ public:
auto winfsp_flush(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc,
PVOID *&ptr) -> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type override;
auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
std::wstring &string_descriptor) -> packet::error_type override;
auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes,
std::uint64_t *descriptor_size,
std::wstring &string_descriptor)
-> packet::error_type override;
auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label)
-> packet::error_type override;
auto
winfsp_mounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_mounted(const std::wstring &location)
-> packet::error_type override;
auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info,
std::string &normalized_name) -> packet::error_type override;
remote::file_info *file_info, std::string &normalized_name)
-> packet::error_type override;
auto
winfsp_overwrite(PVOID file_desc, UINT32 attributes,
auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size,
remote::file_info *file_info) -> packet::error_type override;
remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override;
@ -111,25 +114,26 @@ public:
auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override;
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;
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;
auto winfsp_set_file_size(
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) -> packet::error_type override;
auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
remote::file_info *file_info)
-> packet::error_type override;
auto
winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_unmounted(const std::wstring &location)
-> packet::error_type override;
auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
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) -> packet::error_type override;
PUINT32 bytes_transferred, remote::file_info *file_info)
-> packet::error_type override;
};
} // namespace remote_winfsp
} // namespace repertory
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -21,8 +21,8 @@
*/
// NOTE: Most of the WinFSP pass-through code has been modified from:
// https://github.com/billziss-gh/winfsp/blob/master/tst/passthrough-cpp/passthrough-cpp.cpp
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
#if defined(_WIN32)
#include "comm/packet/packet.hpp"
@ -49,23 +49,23 @@ private:
[[nodiscard]] auto get_next_handle() -> std::uint64_t;
[[nodiscard]] auto
populate_file_info(const std::string &api_path,
remote::file_info &file_info) -> packet::error_type;
[[nodiscard]] auto populate_file_info(const std::string &api_path,
remote::file_info &file_info)
-> packet::error_type;
void populate_stat(const char *path, bool directory, remote::stat &r_stat,
const struct _stat64 &unix_st);
public:
// FUSE Layer
auto fuse_access(const char *path,
const std::int32_t &mask) -> packet::error_type override;
auto fuse_access(const char *path, const std::int32_t &mask)
-> packet::error_type override;
auto fuse_chflags(const char *path,
std::uint32_t flags) -> packet::error_type override;
auto fuse_chflags(const char *path, std::uint32_t flags)
-> packet::error_type override;
auto fuse_chmod(const char *path,
const remote::file_mode &mode) -> packet::error_type override;
auto fuse_chmod(const char *path, const remote::file_mode &mode)
-> packet::error_type override;
auto fuse_chown(const char *path, const remote::user_id &uid,
const remote::group_id &gid) -> packet::error_type override;
@ -84,16 +84,16 @@ public:
const remote::file_handle &handle)
-> packet::error_type override;
auto
fuse_fsync(const char *path, const std::int32_t &datasync,
const remote::file_handle &handle) -> packet::error_type override;
auto fuse_fsync(const char *path, const std::int32_t &datasync,
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_ftruncate(const char *path, const remote::file_offset &size,
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_getattr(const char *path, remote::stat &r_stat,
bool &directory) -> packet::error_type override;
auto fuse_getattr(const char *path, remote::stat &r_stat, bool &directory)
-> packet::error_type override;
/*packet::error_type fuse_getxattr(const char *path, const char *name, char
*value, const remote::file_size &size) override ;
@ -110,41 +110,43 @@ public:
const remote::file_size &size) override
;*/
auto fuse_mkdir(const char *path,
const remote::file_mode &mode) -> packet::error_type override;
auto fuse_mkdir(const char *path, const remote::file_mode &mode)
-> packet::error_type override;
auto fuse_opendir(const char *path,
remote::file_handle &handle) -> packet::error_type override;
auto fuse_opendir(const char *path, remote::file_handle &handle)
-> packet::error_type override;
auto fuse_create(const char *path, const remote::file_mode &mode,
const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override;
const remote::open_flags &flags, remote::file_handle &handle)
-> packet::error_type override;
auto fuse_open(const char *path, const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override;
auto
fuse_read(const char *path, char *buffer, const remote::file_size &read_size,
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 override;
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_rename(const char *from,
const char *to) -> packet::error_type override;
auto fuse_rename(const char *from, const char *to)
-> packet::error_type override;
auto
fuse_write(const char *path, const char *buffer,
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) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_write_base64(
const char *path, const char *buffer, const remote::file_size &write_size,
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) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_readdir(const char *path, const remote::file_offset &offset,
const remote::file_handle &handle,
std::string &item_path) -> packet::error_type override;
const remote::file_handle &handle, std::string &item_path)
-> packet::error_type override;
auto fuse_release(const char *path, const remote::file_handle &handle)
-> packet::error_type override;
@ -157,8 +159,8 @@ public:
auto fuse_rmdir(const char *path) -> packet::error_type override;
auto fuse_setattr_x(const char *path,
remote::setattr_x &attr) -> packet::error_type override;
auto fuse_setattr_x(const char *path, remote::setattr_x &attr)
-> packet::error_type override;
auto fuse_setbkuptime(const char *path, const remote::file_time &bkuptime)
-> packet::error_type override;
@ -191,8 +193,8 @@ public:
auto fuse_unlink(const char *path) -> packet::error_type override;
auto fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0,
std::uint64_t op1) -> packet::error_type override;
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 {}
@ -201,20 +203,21 @@ public:
auto json_create_directory_snapshot(const std::string &path, json &json_data)
-> packet::error_type override;
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;
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;
auto json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle)
-> packet::error_type override;
// WinFSP Layer
auto winfsp_can_delete(PVOID file_desc,
PWSTR file_name) -> packet::error_type override;
auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type override;
auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override;
BOOLEAN &was_deleted) -> packet::error_type override;
auto winfsp_close(PVOID file_desc) -> packet::error_type override;
@ -227,32 +230,33 @@ public:
auto winfsp_flush(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc,
PVOID *&ptr) -> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type override;
auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
std::wstring &string_descriptor) -> packet::error_type override;
auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes,
std::uint64_t *descriptor_size,
std::wstring &string_descriptor)
-> packet::error_type override;
auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label)
-> packet::error_type override;
auto
winfsp_mounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_mounted(const std::wstring &location)
-> packet::error_type override;
auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info,
std::string &normalized_name) -> packet::error_type override;
remote::file_info *file_info, std::string &normalized_name)
-> packet::error_type override;
auto
winfsp_overwrite(PVOID file_desc, UINT32 attributes,
auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size,
remote::file_info *file_info) -> packet::error_type override;
remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override;
@ -263,26 +267,27 @@ public:
auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override;
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;
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;
auto winfsp_set_file_size(
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) -> packet::error_type override;
auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
remote::file_info *file_info)
-> packet::error_type override;
auto
winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_unmounted(const std::wstring &location)
-> packet::error_type override;
auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
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) -> packet::error_type override;
PUINT32 bytes_transferred, remote::file_info *file_info)
-> packet::error_type override;
};
} // namespace remote_winfsp
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
#if defined(_WIN32)
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
@ -50,10 +50,10 @@ public:
private:
app_config &config_;
lock_data &lock_;
remote_winfsp_drive &drive_;
const std::vector<std::string> drive_args_;
FileSystemHost host_;
lock_data &lock_;
protected:
auto OnStart(ULONG, PWSTR *) -> NTSTATUS override;
@ -75,8 +75,8 @@ private:
static void set_file_info(FileInfo &dest, const remote::file_info &src);
public:
auto CanDelete(PVOID file_node, PVOID file_desc,
PWSTR file_name) -> NTSTATUS override;
auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name)
-> NTSTATUS override;
VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name,
ULONG flags) override;
@ -88,11 +88,11 @@ 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) -> NTSTATUS override;
auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info)
-> NTSTATUS override;
auto GetFileInfo(PVOID file_node, PVOID file_desc,
FileInfo *file_info) -> NTSTATUS override;
auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info)
-> NTSTATUS override;
auto GetSecurityByName(PWSTR file_name, PUINT32 attributes,
PSECURITY_DESCRIPTOR descriptor,
@ -107,8 +107,8 @@ public:
auto Mounted(PVOID host) -> NTSTATUS override;
auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
PVOID *file_node, PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS override;
PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi)
-> NTSTATUS override;
auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size,
@ -122,8 +122,8 @@ public:
PULONG bytes_transferred) -> NTSTATUS override;
auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name,
PWSTR new_file_name,
BOOLEAN replace_if_exists) -> NTSTATUS override;
PWSTR new_file_name, BOOLEAN replace_if_exists)
-> NTSTATUS override;
auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time,
@ -131,15 +131,15 @@ public:
FileInfo *file_info) -> NTSTATUS override;
auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
FileInfo *file_info) -> NTSTATUS override;
BOOLEAN set_allocation_size, FileInfo *file_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 *file_info)
-> NTSTATUS override;
void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); }
@ -152,4 +152,4 @@ public:
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
#define INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
#define REPERTORY_INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
#if defined(_WIN32)
#include "drives/eviction.hpp"
@ -53,11 +53,11 @@ private:
~winfsp_service() override = default;
private:
lock_data &lock_;
winfsp_drive &drive_;
const std::vector<std::string> drive_args_;
FileSystemHost host_;
app_config &config_;
winfsp_drive &drive_;
std::vector<std::string> drive_args_;
FileSystemHost host_;
lock_data &lock_;
protected:
auto OnStart(ULONG, PWSTR *) -> NTSTATUS override;
@ -73,24 +73,33 @@ private:
std::unique_ptr<file_manager> fm_;
std::unique_ptr<eviction> eviction_;
std::unique_ptr<remote_winfsp::remote_server> remote_server_;
std::mutex stop_all_mtx_;
private:
static auto
parse_mount_location(const std::wstring &mount_location) -> std::string;
[[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,
bool raise_on_failure_only = false) const
-> NTSTATUS;
static auto parse_mount_location(const std::wstring &mount_location)
-> std::string;
void populate_file_info(const std::string &api_path, std::uint64_t file_size,
const api_meta_map &meta,
FSP_FSCTL_OPEN_FILE_INFO &ofi);
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);
FSP_FSCTL_FILE_INFO &fi) const;
static void set_file_info(remote::file_info &dest,
const FSP_FSCTL_FILE_INFO &src);
void stop_all();
public:
auto CanDelete(PVOID file_node, PVOID file_desc,
PWSTR file_name) -> NTSTATUS override;
auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name)
-> NTSTATUS override;
VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name,
ULONG flags) override;
@ -102,8 +111,8 @@ 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) -> NTSTATUS override;
auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info)
-> NTSTATUS override;
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
-> std::uint64_t override;
@ -111,24 +120,25 @@ public:
[[nodiscard]] auto get_directory_items(const std::string &api_path) const
-> directory_item_list override;
auto GetFileInfo(PVOID file_node, PVOID file_desc,
FileInfo *file_info) -> NTSTATUS override;
auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info)
-> NTSTATUS override;
[[nodiscard]] auto
get_file_size(const std::string &api_path) const -> std::uint64_t override;
[[nodiscard]] auto get_file_size(const std::string &api_path) const
-> std::uint64_t override;
[[nodiscard]] auto
get_item_meta(const std::string &api_path,
api_meta_map &meta) const -> api_error override;
[[nodiscard]] auto get_item_meta(const std::string &api_path,
api_meta_map &meta) const
-> api_error override;
[[nodiscard]] auto
get_item_meta(const std::string &api_path, const std::string &name,
std::string &value) const -> api_error override;
[[nodiscard]] auto get_item_meta(const std::string &api_path,
const std::string &name,
std::string &value) const
-> api_error override;
[[nodiscard]] auto
get_security_by_name(PWSTR file_name, PUINT32 attributes,
[[nodiscard]] auto get_security_by_name(PWSTR file_name, PUINT32 attributes,
PSECURITY_DESCRIPTOR descriptor,
std::uint64_t *descriptor_size) -> NTSTATUS override;
std::uint64_t *descriptor_size)
-> NTSTATUS override;
auto GetSecurityByName(PWSTR file_name, PUINT32 attributes,
PSECURITY_DESCRIPTOR descriptor,
@ -152,16 +162,16 @@ public:
auto Mounted(PVOID host) -> NTSTATUS override;
auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
PVOID *file_node, PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS override;
PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi)
-> NTSTATUS override;
auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size,
FileInfo *file_info) -> NTSTATUS override;
[[nodiscard]] auto
populate_file_info(const std::string &api_path,
remote::file_info &file_info) -> api_error override;
[[nodiscard]] auto populate_file_info(const std::string &api_path,
remote::file_info &file_info) const
-> api_error override;
auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
ULONG length, PULONG bytes_transferred) -> NTSTATUS override;
@ -171,8 +181,8 @@ public:
PULONG bytes_transferred) -> NTSTATUS override;
auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name,
PWSTR new_file_name,
BOOLEAN replace_if_exists) -> NTSTATUS override;
PWSTR new_file_name, BOOLEAN replace_if_exists)
-> NTSTATUS override;
auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time,
@ -180,15 +190,15 @@ public:
FileInfo *file_info) -> NTSTATUS override;
auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
FileInfo *file_info) -> NTSTATUS override;
BOOLEAN set_allocation_size, FileInfo *file_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 *file_info)
-> NTSTATUS override;
void shutdown();
@ -200,4 +210,4 @@ public:
} // namespace repertory
#endif // _WIN32
#endif // INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,10 +19,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
#define INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
#include "events/event_system.hpp"
#include "types/repertory.hpp"
namespace repertory {
class console_consumer final {
@ -36,8 +37,8 @@ public:
~console_consumer();
private:
void process_event(const event &e) const;
static void process_event(const i_event &evt);
};
} // namespace repertory
#endif // INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
#endif // REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,13 +19,14 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
#define INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
#include "events/event_system.hpp"
#include "types/repertory.hpp"
namespace repertory {
class logging_consumer {
class logging_consumer final {
E_CONSUMER();
public:
@ -39,8 +40,8 @@ private:
5ULL};
private:
void process_event(const event &event) const;
static void process_event(const i_event &evt);
};
} // namespace repertory
#endif // INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
#endif // REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_

View File

@ -1,75 +0,0 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 INCLUDE_EVENTS_EVENT_HPP_
#define INCLUDE_EVENTS_EVENT_HPP_
namespace repertory {
enum class event_level {
critical,
error,
warn,
info,
debug,
trace,
};
auto event_level_from_string(std::string level) -> event_level;
auto event_level_to_string(event_level level) -> std::string;
class event {
protected:
explicit event(bool allow_async) : allow_async_(allow_async) {}
event(const std::stringstream &ss, json j, bool allow_async)
: allow_async_(allow_async), ss_(ss.str()), j_(std::move(j)) {}
public:
event(const event &) = delete;
event(event &&) = delete;
auto operator=(const event &) -> event & = delete;
auto operator=(event &&) -> event & = delete;
virtual ~event() = default;
private:
bool allow_async_;
protected:
std::stringstream ss_;
json j_;
public:
[[nodiscard]] virtual auto clone() const -> std::shared_ptr<event> = 0;
[[nodiscard]] auto get_allow_async() const -> bool { return allow_async_; }
[[nodiscard]] virtual auto get_event_level() const -> event_level = 0;
[[nodiscard]] auto get_json() const -> json { return j_; }
[[nodiscard]] virtual auto get_name() const -> std::string = 0;
[[nodiscard]] virtual auto get_single_line() const -> std::string = 0;
};
} // namespace repertory
#endif // INCLUDE_EVENTS_EVENT_HPP_

View File

@ -1,5 +1,5 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,224 +19,107 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
#define INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
#include "events/event.hpp"
#include "events/t_event_system.hpp"
#include "utils/string.hpp"
#ifndef REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
#define REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
namespace repertory {
using event_system = t_event_system<event>;
using event_consumer = event_system::event_consumer;
class i_event;
#define E_CAST(t) ((std::string)t)
#define E_DOUBLE(d) std::to_string(d)
#define E_DOUBLE_PRECISE(dbl_val) \
([](const double &d) -> std::string { \
std::stringstream ss; \
ss << std::fixed << std::setprecision(2) << d; \
return ss.str(); \
})(dbl_val)
#define E_FROM_BOOL(t) std::to_string(t)
#define E_FROM_EXCEPTION(e) std::string(e.what() ? e.what() : "")
#define E_FROM_INT32(t) std::to_string(t)
#define E_FROM_INT64(t) std::to_string(t)
#define E_FROM_UINT16(t) std::to_string(t)
#define E_FROM_STRING_ARRAY(a) \
([](const auto &array) -> std::string { \
std::stringstream ret; \
for (const auto &item : array) { \
ret << (std::string(item) + " "); \
} \
return std::string(ret).TrimRight(); \
})(a)
class event_system final {
private:
static constexpr const std::uint8_t max_queue_retry{
30U,
};
#define E_PERCENT(d) \
([](const double &d) -> std::string { \
std::stringstream ss; \
ss << std::fixed << std::setprecision(2) << d; \
ss << "%"; \
return ss; \
})(d)
#define E_STRING(t) t
#define E_FROM_CURL_CODE(t) std::string(curl_easy_strerror(t))
#define E_FROM_UINT8(t) std::to_string(t)
#define E_FROM_UINT32(t) std::to_string(t)
#define E_FROM_UINT64(t) std::to_string(t)
#define E_FROM_SIZE_T(t) std::to_string(t)
#define E_FROM_API_FILE_ERROR(e) api_error_to_string(e)
const std::uint32_t max_queue_size{
std::thread::hardware_concurrency() * 4U,
};
#define E_PROP(type, name, short_name, ts) \
private: \
void init_##short_name(const type &val) { \
auto ts_val = ts(val); \
ss_ << "|" << #short_name << "|" << ts_val; \
j_[#name] = ts_val; \
} \
\
public: \
[[nodiscard]] auto get_##name() const->json { return j_[#name]; }
static constexpr const std::chrono::seconds queue_wait_secs{
5s,
};
#define E_BEGIN(name, el) \
class name final : public virtual event { \
private: \
name(const std::stringstream &ss, const json &j, bool allow_async) \
: event(ss, j, allow_async) {} \
\
public: \
~name() override = default; \
\
public: \
static const event_level level = event_level::el; \
\
public: \
[[nodiscard]] auto get_name() const -> std::string override { \
return #name; \
} \
\
[[nodiscard]] auto get_event_level() const -> event_level override { \
return name::level; \
} \
\
[[nodiscard]] auto get_single_line() const -> std::string override { \
const auto s = ss_.str(); \
return get_name() + (s.empty() ? "" : s); \
} \
\
[[nodiscard]] auto clone() const -> std::shared_ptr<event> override { \
return std::shared_ptr<name>(new name(ss_, j_, get_allow_async())); \
public:
event_system(const event_system &) = delete;
event_system(event_system &&) = delete;
auto operator=(const event_system &) -> event_system & = delete;
auto operator=(event_system &&) -> event_system & = delete;
protected:
event_system() = default;
~event_system() { stop(); }
public:
class event_consumer final {
public:
explicit event_consumer(std::function<void(const i_event &)> callback)
: callback_(std::move(callback)) {
event_system::instance().attach(this);
}
#define E_END() }
#define E_SIMPLE(event_name, el, allow_async) \
E_BEGIN(event_name, el) \
public: \
event_name() : event(allow_async) {} \
E_END()
event_consumer(std::string_view event_name,
std::function<void(const i_event &)> callback)
: callback_(std::move(callback)) {
event_system::instance().attach(event_name, this);
}
#define E_SIMPLE1(event_name, el, allow_async, type, name, short_name, tc) \
E_BEGIN(event_name, el) \
explicit event_name(const type &tv) : event(allow_async) { \
init_##short_name(tv); \
} \
E_PROP(type, name, short_name, tc) \
E_END()
~event_consumer() { event_system::instance().release(this); }
#define E_SIMPLE2(event_name, el, allow_async, type, name, short_name, tc, \
type2, name2, short_name2, tc2) \
E_BEGIN(event_name, el) \
explicit event_name(const type &tv, const type2 &tv2) : event(allow_async) { \
init_##short_name(tv); \
init_##short_name2(tv2); \
} \
E_PROP(type, name, short_name, tc) \
E_PROP(type2, name2, short_name2, tc2) \
E_END()
public:
event_consumer(const event_consumer &) = delete;
event_consumer(event_consumer &&) = delete;
auto operator=(const event_consumer &) -> event_consumer & = delete;
auto operator=(event_consumer &&) -> event_consumer & = delete;
#define E_SIMPLE3(event_name, el, allow_async, type, name, short_name, tc, \
type2, name2, short_name2, tc2, type3, name3, short_name3, \
tc3) \
E_BEGIN(event_name, el) \
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3) \
: event(allow_async) { \
init_##short_name(tv); \
init_##short_name2(tv2); \
init_##short_name3(tv3); \
} \
E_PROP(type, name, short_name, tc) \
E_PROP(type2, name2, short_name2, tc2) \
E_PROP(type3, name3, short_name3, tc3) \
E_END()
private:
std::function<void(const i_event &)> callback_;
#define E_SIMPLE4(event_name, el, allow_async, type, name, short_name, tc, \
type2, name2, short_name2, tc2, type3, name3, short_name3, \
tc3, type4, name4, short_name4, tc4) \
E_BEGIN(event_name, el) \
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
const type4 &tv4) \
: event(allow_async) { \
init_##short_name(tv); \
init_##short_name2(tv2); \
init_##short_name3(tv3); \
init_##short_name4(tv4); \
} \
E_PROP(type, name, short_name, tc) \
E_PROP(type2, name2, short_name2, tc2) \
E_PROP(type3, name3, short_name3, tc3) \
E_PROP(type4, name4, short_name4, tc4) \
E_END()
public:
void notify_event(const i_event &event) { callback_(event); }
};
#define E_SIMPLE5(event_name, el, allow_async, type, name, short_name, tc, \
type2, name2, short_name2, tc2, type3, name3, short_name3, \
tc3, type4, name4, short_name4, tc4, type5, name5, \
short_name5, tc5) \
E_BEGIN(event_name, el) \
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
const type4 &tv4, const type5 &tv5) \
: event(allow_async) { \
init_##short_name(tv); \
init_##short_name2(tv2); \
init_##short_name3(tv3); \
init_##short_name4(tv4); \
init_##short_name5(tv5); \
} \
E_PROP(type, name, short_name, tc) \
E_PROP(type2, name2, short_name2, tc2) \
E_PROP(type3, name3, short_name3, tc3) \
E_PROP(type4, name4, short_name4, tc4) \
E_PROP(type5, name5, short_name5, tc5) \
E_END()
private:
static event_system instance_;
#define E_SIMPLE6(event_name, el, allow_async, type, name, short_name, tc, \
type2, name2, short_name2, tc2, type3, name3, short_name3, \
tc3, type4, name4, short_name4, tc4, type5, name5, \
short_name5, tc5, type6, name6, short_name6, tc6) \
E_BEGIN(event_name, el) \
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
const type4 &tv4, const type5 &tv5, const type6 &tv6) \
: event(allow_async) { \
init_##short_name(tv); \
init_##short_name2(tv2); \
init_##short_name3(tv3); \
init_##short_name4(tv4); \
init_##short_name5(tv5); \
init_##short_name6(tv6); \
} \
E_PROP(type, name, short_name, tc) \
E_PROP(type2, name2, short_name2, tc2) \
E_PROP(type3, name3, short_name3, tc3) \
E_PROP(type4, name4, short_name4, tc4) \
E_PROP(type5, name5, short_name5, tc5) \
E_PROP(type6, name6, short_name6, tc6) \
E_END()
public:
[[nodiscard]] static auto instance() -> event_system &;
#define E_SIMPLE7(event_name, el, allow_async, type, name, short_name, tc, \
type2, name2, short_name2, tc2, type3, name3, short_name3, \
tc3, type4, name4, short_name4, tc4, type5, name5, \
short_name5, tc5, type6, name6, short_name6, tc6, type7, \
name7, short_name7, tc7) \
E_BEGIN(event_name, el) \
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
const type4 &tv4, const type5 &tv5, const type6 &tv6, \
const type7 &tv7) \
: event(allow_async) { \
init_##short_name(tv); \
init_##short_name2(tv2); \
init_##short_name3(tv3); \
init_##short_name4(tv4); \
init_##short_name5(tv5); \
init_##short_name6(tv6); \
init_##short_name7(tv7); \
} \
E_PROP(type, name, short_name, tc) \
E_PROP(type2, name2, short_name2, tc2) \
E_PROP(type3, name3, short_name3, tc3) \
E_PROP(type4, name4, short_name4, tc4) \
E_PROP(type5, name5, short_name5, tc5) \
E_PROP(type6, name6, short_name6, tc6) \
E_PROP(type7, name7, short_name7, tc7) \
E_END()
private:
std::unordered_map<std::string, std::deque<event_consumer *>>
event_consumers_;
std::recursive_mutex consumer_mutex_;
std::vector<std::shared_ptr<i_event>> event_list_;
std::condition_variable event_notify_;
std::mutex event_mutex_;
std::unique_ptr<std::thread> event_thread_;
std::mutex run_mutex_;
stop_type stop_requested_{false};
private:
[[nodiscard]] auto get_stop_requested() const -> bool;
void process_events();
void queue_event(std::shared_ptr<i_event> evt);
public:
void attach(event_consumer *consumer);
void attach(std::string_view event_name, event_consumer *consumer);
template <typename evt_t, typename... arg_t> void raise(arg_t &&...args) {
queue_event(std::make_shared<evt_t>(std::forward<arg_t>(args)...));
}
void release(event_consumer *consumer);
void start();
void stop();
};
using event_consumer = event_system::event_consumer;
#define E_CONSUMER() \
private: \
@ -244,19 +127,15 @@ private: \
#define E_CONSUMER_RELEASE() event_consumers_.clear()
#define E_SUBSCRIBE(name, callback) \
#define E_SUBSCRIBE(event, callback) \
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
#name, [this](const event &evt) { callback(evt); }))
#define E_SUBSCRIBE_EXACT(name, callback) \
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
#name, [this](const event &evt) { \
callback(dynamic_cast<const name &>(evt)); \
event::name, [this](const i_event &evt) { \
callback(dynamic_cast<const event &>(evt)); \
}))
#define E_SUBSCRIBE_ALL(callback) \
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
[this](const event &evt) { callback(evt); }))
[this](const i_event &evt) { callback(evt); }))
} // namespace repertory
#endif // INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
#endif // REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_

View File

@ -1,295 +0,0 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 INCLUDE_EVENTS_EVENTS_HPP_
#define INCLUDE_EVENTS_EVENTS_HPP_
#include "events/event_system.hpp"
#include "types/repertory.hpp"
#include "utils/utils.hpp"
namespace repertory {
// clang-format off
E_SIMPLE2(curl_error, error, true,
std::string, url, url, E_STRING,
CURLcode, res, res, E_FROM_CURL_CODE
);
E_SIMPLE3(debug_log, debug, true,
std::string, function, func, E_STRING,
std::string, api_path, ap, E_STRING,
std::string, data, data, E_STRING
);
E_SIMPLE1(directory_removed, info, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE2(directory_removed_externally, warn, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING
);
E_SIMPLE2(directory_remove_failed, error, true,
std::string, api_path, ap, E_STRING,
std::string, error, err, E_STRING
);
E_SIMPLE2(drive_mount_failed, error, true,
std::string, location, loc, E_STRING,
std::string, result, res, E_STRING
);
E_SIMPLE1(drive_mounted, info, true,
std::string, location, loc, E_STRING
);
E_SIMPLE1(drive_mount_result, info, true,
std::string, result, res, E_STRING
);
E_SIMPLE1(drive_unmount_pending, info, true,
std::string, location, loc, E_STRING
);
E_SIMPLE1(drive_unmounted, info, true,
std::string, location, loc, E_STRING
);
E_SIMPLE1(event_level_changed, info, true,
std::string, new_event_level, level, E_STRING
);
E_SIMPLE1(failed_upload_queued, error, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE1(failed_upload_removed, warn, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE1(failed_upload_retry, info, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE2(file_get_failed, error, true,
std::string, api_path, ap, E_STRING,
std::string, error, err, E_STRING
);
E_SIMPLE1(file_get_api_list_failed, error, true,
std::string, error, err, E_STRING
);
E_SIMPLE1(file_pinned, info, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE3(file_read_bytes_failed, error, true,
std::string, api_path, ap, E_STRING,
std::string, error, err, E_STRING,
std::size_t, retry, retry, E_FROM_SIZE_T
);
E_SIMPLE1(file_removed, debug, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE2(file_removed_externally, warn, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING
);
E_SIMPLE2(file_remove_failed, error, true,
std::string, api_path, ap, E_STRING,
std::string, error, err, E_STRING
);
E_SIMPLE3(file_rename_failed, error, true,
std::string, from_api_path, FROM, E_STRING,
std::string, to_api_path, TO, E_STRING,
std::string, error, err, E_STRING
);
E_SIMPLE2(file_get_size_failed, error, true,
std::string, api_path, ap, E_STRING,
std::string, error, err, E_STRING
);
E_SIMPLE3(filesystem_item_added, debug, true,
std::string, api_path, ap, E_STRING,
std::string, parent, parent, E_STRING,
bool, directory, dir, E_FROM_BOOL
);
E_SIMPLE4(filesystem_item_closed, trace, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING,
bool, directory, dir, E_FROM_BOOL,
bool, changed, changed, E_FROM_BOOL
);
E_SIMPLE5(filesystem_item_handle_closed, trace, true,
std::string, api_path, ap, E_STRING,
std::uint64_t, handle, handle, E_FROM_UINT64,
std::string, source, src, E_STRING,
bool, directory, dir, E_FROM_BOOL,
bool, changed, changed, E_FROM_BOOL
);
E_SIMPLE4(filesystem_item_handle_opened, trace, true,
std::string, api_path, ap, E_STRING,
std::uint64_t, handle, handle, E_FROM_UINT64,
std::string, source, src, E_STRING,
bool, directory, dir, E_FROM_BOOL
);
E_SIMPLE2(filesystem_item_evicted, info, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING
);
E_SIMPLE3(filesystem_item_opened, trace, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING,
bool, directory, dir, E_FROM_BOOL
);
E_SIMPLE1(file_unpinned, info, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE4(file_upload_completed, info, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING,
api_error, result, res, E_FROM_API_FILE_ERROR,
bool, cancelled, cancel, E_FROM_BOOL
);
E_SIMPLE3(file_upload_failed, error, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING,
std::string, error, err, E_STRING
);
E_SIMPLE2(file_upload_not_found, warn, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING
);
E_SIMPLE2(file_upload_queued, info, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING
);
E_SIMPLE1(file_upload_removed, debug, true,
std::string, api_path, ap, E_STRING
);
E_SIMPLE3(file_upload_retry, info, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING,
api_error, result, res, E_FROM_API_FILE_ERROR
);
E_SIMPLE2(file_upload_started, info, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING
);
E_SIMPLE1(orphaned_file_deleted, warn, true,
std::string, source, src, E_STRING
);
E_SIMPLE1(orphaned_file_detected, warn, true,
std::string, source, src, E_STRING
);
E_SIMPLE3(orphaned_file_processing_failed, error, true,
std::string, source, src, E_STRING,
std::string, dest, dest, E_STRING,
std::string, result, res, E_STRING
);
E_SIMPLE1(orphaned_source_file_detected, info, true,
std::string, source, src, E_STRING
);
E_SIMPLE1(orphaned_source_file_removed, info, true,
std::string, source, src, E_STRING
);
E_SIMPLE1(polling_item_begin, debug, true,
std::string, item_name, item, E_STRING
);
E_SIMPLE1(polling_item_end, debug, true,
std::string, item_name, item, E_STRING
);
E_SIMPLE2(provider_offline, error, true,
std::string, host_name_or_ip, host, E_STRING,
std::uint16_t, port, port, E_FROM_UINT16
);
E_SIMPLE2(provider_upload_begin, info, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING
);
E_SIMPLE3(provider_upload_end, info, true,
std::string, api_path, ap, E_STRING,
std::string, source, src, E_STRING,
api_error, result, res, E_FROM_API_FILE_ERROR
);
E_SIMPLE2(repertory_exception, error, true,
std::string, function, func, E_STRING,
std::string, message, msg, E_STRING
);
E_SIMPLE1(rpc_server_exception, error, true,
std::string, exception, exception, E_STRING
);
E_SIMPLE1(service_shutdown_begin, debug, true,
std::string, service, svc, E_STRING
);
E_SIMPLE1(service_shutdown_end, debug, true,
std::string, service, svc, E_STRING
);
E_SIMPLE1(service_started, debug, true,
std::string, service, svc, E_STRING
);
E_SIMPLE(unmount_requested, info, true);
#if !defined(_WIN32)
E_SIMPLE2(unmount_result, info, true,
std::string, location, loc, E_STRING,
std::string, result, res, E_STRING
);
#endif
// clang-format on
} // namespace repertory
#endif // INCLUDE_EVENTS_EVENTS_HPP_

View File

@ -0,0 +1,40 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_I_EVENT_HPP_
#define REPERTORY_INCLUDE_EVENTS_I_EVENT_HPP_
#include "types/repertory.hpp"
namespace repertory {
class i_event {
INTERFACE_SETUP(i_event);
public:
[[nodiscard]] virtual auto get_event_level() const -> event_level = 0;
[[nodiscard]] virtual auto get_name() const -> std::string_view = 0;
[[nodiscard]] virtual auto get_single_line() const -> std::string = 0;
};
} // namespace repertory
#endif // REPERTORY_INCLUDE_EVENTS_EVENT_HPP_

View File

@ -1,193 +0,0 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
#define INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
#include "events/event.hpp"
#include "utils/collection.hpp"
#include "utils/utils.hpp"
namespace repertory {
template <typename event_type> class t_event_system final {
public:
t_event_system(const t_event_system &) = delete;
t_event_system(t_event_system &&) = delete;
auto operator=(const t_event_system &) -> t_event_system & = delete;
auto operator=(t_event_system &&) -> t_event_system & = delete;
protected:
t_event_system() = default;
~t_event_system() { stop(); }
public:
class event_consumer final {
public:
explicit event_consumer(std::function<void(const event &)> callback)
: callback_(std::move(callback)) {
t_event_system::instance().attach(this);
}
event_consumer(const std::string &event_name,
std::function<void(const event &)> callback)
: callback_(std::move(callback)) {
t_event_system::instance().attach(event_name, this);
}
~event_consumer() { t_event_system::instance().release(this); }
public:
event_consumer(const event_consumer &) = delete;
event_consumer(event_consumer &&) = delete;
auto operator=(const event_consumer &) -> event_consumer & = delete;
auto operator=(event_consumer &&) -> event_consumer & = delete;
private:
std::function<void(const event &)> callback_;
public:
void notify_event(const event &event) { callback_(event); }
};
private:
static t_event_system event_system_;
public:
static auto instance() -> t_event_system &;
private:
std::unordered_map<std::string, std::deque<event_consumer *>>
event_consumers_;
std::recursive_mutex consumer_mutex_;
std::vector<std::shared_ptr<event_type>> event_list_;
std::condition_variable event_notify_;
std::mutex event_mutex_;
std::unique_ptr<std::thread> event_thread_;
std::mutex run_mutex_;
stop_type stop_requested_ = false;
private:
void process_events() {
std::vector<std::shared_ptr<event_type>> events;
{
unique_mutex_lock lock(event_mutex_);
if (not stop_requested_ && event_list_.empty()) {
event_notify_.wait_for(lock, 1s);
}
if (not event_list_.empty()) {
events.insert(events.end(), event_list_.begin(), event_list_.end());
event_list_.clear();
}
}
const auto notify_events = [this](const std::string &name,
const event_type &event) {
std::deque<std::future<void>> futures;
recur_mutex_lock lock(consumer_mutex_);
if (event_consumers_.find(name) != event_consumers_.end()) {
for (auto *consumer : event_consumers_[name]) {
if (event.get_allow_async()) {
futures.emplace_back(
std::async(std::launch::async, [consumer, &event]() {
consumer->notify_event(event);
}));
} else {
consumer->notify_event(event);
}
}
}
while (not futures.empty()) {
futures.front().get();
futures.pop_front();
}
};
for (const auto &evt : events) {
notify_events("", *evt.get());
notify_events(evt->get_name(), *evt.get());
}
}
void queue_event(std::shared_ptr<event_type> evt) {
mutex_lock lock(event_mutex_);
event_list_.push_back(std::move(evt));
event_notify_.notify_all();
}
public:
void attach(event_consumer *consumer) {
recur_mutex_lock lock(consumer_mutex_);
event_consumers_[""].push_back(consumer);
}
void attach(const std::string &event_name, event_consumer *consumer) {
recur_mutex_lock lock(consumer_mutex_);
event_consumers_[event_name].push_back(consumer);
}
template <typename event_t, typename... arg_t> void raise(arg_t &&...args) {
queue_event(std::make_shared<event_t>(std::forward<arg_t>(args)...));
}
void release(event_consumer *consumer) {
recur_mutex_lock lock(consumer_mutex_);
auto iter = std::find_if(event_consumers_.begin(), event_consumers_.end(),
[&](const auto &item) -> bool {
return utils::collection::includes(item.second,
consumer);
});
if (iter != event_consumers_.end()) {
utils::collection::remove_element((*iter).second, consumer);
}
}
void start() {
mutex_lock lock(run_mutex_);
if (not event_thread_) {
stop_requested_ = false;
event_thread_ = std::make_unique<std::thread>([this]() {
while (not stop_requested_) {
process_events();
}
});
}
}
void stop() {
mutex_lock lock(run_mutex_);
if (event_thread_) {
stop_requested_ = true;
event_notify_.notify_all();
event_thread_->join();
event_thread_.reset();
process_events();
}
}
};
} // namespace repertory
#endif // INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_

View File

@ -0,0 +1,74 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_CURL_ERROR_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_CURL_ERROR_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct curl_error final : public i_event {
curl_error() = default;
curl_error(CURLcode code_, std::string_view function_name_, std::string url_)
: code(code_),
function_name(std::string{function_name_}),
url(std::move(url_)) {}
static constexpr const event_level level{event_level::error};
static constexpr const std::string_view name{"curl_error"};
CURLcode code{};
std::string function_name;
std::string url;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|url|{}|code|{}", name, function_name, url,
static_cast<int>(code));
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::curl_error> {
static void to_json(json &data, const repertory::curl_error &value) {
data["code"] = value.code;
data["function_name"] = value.function_name;
data["url"] = value.url;
}
static void from_json(const json &data, repertory::curl_error &value) {
data.at("code").get_to<CURLcode>(value.code);
data.at("function_name").get_to<std::string>(value.function_name);
data.at("url").get_to<std::string>(value.url);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_CURL_ERROR_HPP_

View File

@ -0,0 +1,68 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DEBUG_LOG_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DEBUG_LOG_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)) {}
static constexpr const event_level level{event_level::debug};
static constexpr const std::string_view name{"debug_log"};
std::string function_name;
std::string msg;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|msg|{}", name, function_name, msg);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::debug_log> {
static void to_json(json &data, const repertory::debug_log &value) {
data["function_name"] = value.function_name;
data["msg"] = value.msg;
}
static void from_json(const json &data, repertory::debug_log &value) {
data.at("function_name").get_to<std::string>(value.function_name);
data.at("msg").get_to<std::string>(value.msg);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DEBUG_LOG_HPP_

View File

@ -0,0 +1,78 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DIRECTORY_REMOVE_FAILED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DIRECTORY_REMOVE_FAILED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct directory_remove_failed final : public i_event {
directory_remove_failed() = default;
directory_remove_failed(std::string api_path_, api_error error_,
std::string_view function_name_)
: api_path(std::move(api_path_)),
error(error_),
function_name(std::string(function_name_)) {}
static constexpr const event_level level{event_level::error};
static constexpr const std::string_view name{"directory_remove_failed"};
std::string api_path;
api_error error{};
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|error|{}", name, function_name,
api_path, api_error_to_string(error));
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::directory_remove_failed> {
static void to_json(json &data,
const repertory::directory_remove_failed &value) {
data["api_path"] = value.api_path;
data["error"] = repertory::api_error_to_string(value.error);
data["function_name"] = value.function_name;
}
static void from_json(const json &data,
repertory::directory_remove_failed &value) {
data.at("api_path").get_to<std::string>(value.api_path);
value.error =
repertory::api_error_from_string(data.at("error").get<std::string>());
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DIRECTORY_REMOVE_FAILED_HPP_

View File

@ -0,0 +1,69 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DIRECTORY_REMOVED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DIRECTORY_REMOVED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)) {}
static constexpr const event_level level{event_level::debug};
static constexpr const std::string_view name{"directory_removed"};
std::string api_path;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}", name, function_name, api_path);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::directory_removed> {
static void to_json(json &data, const repertory::directory_removed &value) {
data["api_path"] = value.api_path;
data["function_name"] = value.function_name;
}
static void from_json(const json &data, repertory::directory_removed &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DIRECTORY_REMOVED_HPP_

View File

@ -0,0 +1,78 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DIRECTORY_REMOVED_EXTERNALLY_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DIRECTORY_REMOVED_EXTERNALLY_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct directory_removed_externally final : public i_event {
directory_removed_externally() = default;
directory_removed_externally(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_)) {}
static constexpr const event_level level{event_level::warn};
static constexpr const std::string_view name{"directory_removed_externally"};
std::string api_path;
std::string function_name;
std::string source_path;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|src|{}", name, function_name, api_path,
source_path);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::directory_removed_externally> {
static void to_json(json &data,
const repertory::directory_removed_externally &value) {
data["api_path"] = value.api_path;
data["function_name"] = value.function_name;
data["source_path"] = value.source_path;
}
static void from_json(const json &data,
repertory::directory_removed_externally &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("function_name").get_to<std::string>(value.function_name);
data.at("source_path").get_to<std::string>(value.source_path);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DIRECTORY_REMOVED_EXTERNALLY_HPP_

View File

@ -0,0 +1,75 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_BEGIN_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_BEGIN_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct download_begin final : public i_event {
download_begin() = default;
download_begin(std::string api_path_, std::string 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_)) {}
static constexpr const event_level level{event_level::info};
static constexpr const std::string_view name{"download_begin"};
std::string api_path;
std::string dest_path;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}", name, function_name, api_path,
dest_path);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_begin> {
static void to_json(json &data, const repertory::download_begin &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
}
static void from_json(const json &data, repertory::download_begin &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_BEGIN_HPP_

View File

@ -0,0 +1,80 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_END_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_END_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)),
error(error_),
function_name(std::string(function_name_)) {}
static constexpr const event_level level{event_level::info};
static constexpr const std::string_view name{"download_end"};
std::string api_path;
std::string dest_path;
api_error error{};
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}|error|{}", name, function_name,
api_path, dest_path, api_error_to_string(error));
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_end> {
static void to_json(json &data, const repertory::download_end &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["error"] = repertory::api_error_to_string(value.error);
data["function_name"] = value.function_name;
}
static void from_json(const json &data, repertory::download_end &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
value.error =
repertory::api_error_from_string(data.at("error").get<std::string>());
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_END_HPP_

View File

@ -0,0 +1,79 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_PROGRESS_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_PROGRESS_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct download_progress final : public i_event {
download_progress() = default;
download_progress(std::string api_path_, std::string 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_)),
progress(progress_) {}
static constexpr const event_level level{event_level::info};
static constexpr const std::string_view name{"download_progress"};
std::string api_path;
std::string dest_path;
std::string function_name;
double progress{};
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}|prog|{}", name, function_name,
api_path, dest_path, progress);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_progress> {
static void to_json(json &data, const repertory::download_progress &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
data["progress"] = value.progress;
}
static void from_json(const json &data, repertory::download_progress &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
data.at("progress").get_to<double>(value.progress);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_PROGRESS_HPP_

View File

@ -0,0 +1,81 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_RESTORE_FAILED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESTORE_FAILED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)) {}
static constexpr const event_level level{event_level::error};
static constexpr const std::string_view name{"download_restore_failed"};
std::string api_path;
std::string dest_path;
std::string error;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}|error|{}", name, function_name,
api_path, dest_path, error);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_restore_failed> {
static void to_json(json &data,
const repertory::download_restore_failed &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["error"] = value.error;
data["function_name"] = value.function_name;
}
static void from_json(const json &data,
repertory::download_restore_failed &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("error").get_to<std::string>(value.error);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESTORE_FAILED_HPP_

View File

@ -0,0 +1,75 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_RESTORED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESTORED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct download_restored final : public i_event {
download_restored() = default;
download_restored(std::string api_path_, std::string 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_)) {}
static constexpr const event_level level{event_level::info};
static constexpr const std::string_view name{"download_restored"};
std::string api_path;
std::string dest_path;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}", name, function_name, api_path,
dest_path);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_restored> {
static void to_json(json &data, const repertory::download_restored &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
}
static void from_json(const json &data, repertory::download_restored &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESTORED_HPP_

View File

@ -0,0 +1,82 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_RESUME_ADD_FAILED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESUME_ADD_FAILED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_,
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_)) {}
static constexpr const event_level level{event_level::error};
static constexpr const std::string_view name{"download_resume_add_failed"};
std::string api_path;
std::string dest_path;
std::string error;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}|error|{}", name, function_name,
api_path, dest_path, error);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_resume_add_failed> {
static void to_json(json &data,
const repertory::download_resume_add_failed &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["error"] = value.error;
data["function_name"] = value.function_name;
}
static void from_json(const json &data,
repertory::download_resume_add_failed &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("error").get_to<std::string>(value.error);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESUME_ADD_FAILED_HPP_

View File

@ -0,0 +1,77 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_RESUME_ADDED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESUME_ADDED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_,
std::string_view function_name_)
: api_path(std::move(api_path_)),
dest_path(std::move(dest_path_)),
function_name(std::string(function_name_)) {}
static constexpr const event_level level{event_level::debug};
static constexpr const std::string_view name{"download_resume_added"};
std::string api_path;
std::string dest_path;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}", name, function_name, api_path,
dest_path);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_resume_added> {
static void to_json(json &data,
const repertory::download_resume_added &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
}
static void from_json(const json &data,
repertory::download_resume_added &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESUME_ADDED_HPP_

View File

@ -0,0 +1,77 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_RESUME_REMOVED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESUME_REMOVED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_,
std::string_view function_name_)
: api_path(std::move(api_path_)),
dest_path(std::move(dest_path_)),
function_name(std::string(function_name_)) {}
static constexpr const event_level level{event_level::debug};
static constexpr const std::string_view name{"download_resume_removed"};
std::string api_path;
std::string dest_path;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}", name, function_name, api_path,
dest_path);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_resume_removed> {
static void to_json(json &data,
const repertory::download_resume_removed &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
}
static void from_json(const json &data,
repertory::download_resume_removed &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_RESUME_REMOVED_HPP_

View File

@ -0,0 +1,82 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DOWNLOAD_TYPE_SELECTED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_TYPE_SELECTED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_,
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_)),
type(type_) {}
static constexpr const event_level level{event_level::debug};
static constexpr const std::string_view name{"download_type_selected"};
std::string api_path;
std::string dest_path;
std::string function_name;
download_type type{};
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}|type|{}", name, function_name,
api_path, dest_path, download_type_to_string(type));
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_type_selected> {
static void to_json(json &data,
const repertory::download_type_selected &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
data["type"] = repertory::download_type_to_string(value.type);
}
static void from_json(const json &data,
repertory::download_type_selected &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
value.type = repertory::download_type_from_string(
data.at("type").get<std::string>());
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_TYPE_SELECTED_HPP_

View File

@ -0,0 +1,78 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DRIVE_MOUNT_FAILED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_MOUNT_FAILED_HPP_
#if defined(_WIN32)
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)
: error(error_),
function_name(std::string(function_name_)),
mount_location(std::move(mount_location_)) {}
static constexpr const event_level level{event_level::error};
static constexpr const std::string_view name{"drive_mount_failed"};
NTSTATUS error{};
std::string function_name;
std::string mount_location;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|location|{}|status|{}", name, function_name,
mount_location, error);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::drive_mount_failed> {
static void to_json(json &data, const repertory::drive_mount_failed &value) {
data["error"] = value.error;
data["function_name"] = value.function_name;
data["mount_location"] = value.mount_location;
}
static void from_json(const json &data,
repertory::drive_mount_failed &value) {
data.at("error").get_to<NTSTATUS>(value.error);
data.at("function_name").get_to<std::string>(value.function_name);
data.at("mount_location").get_to<std::string>(value.mount_location);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // defined(_WIN32)
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_MOUNT_FAILED_HPP_

View File

@ -0,0 +1,76 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DRIVE_MOUNT_RESULT_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_MOUNT_RESULT_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)) {}
static constexpr const event_level level{event_level::info};
static constexpr const std::string_view name{"drive_mount_result"};
std::string function_name;
std::string mount_location;
std::string result;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|location|{}|result|{}", name, function_name,
mount_location, result);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::drive_mount_result> {
static void to_json(json &data, const repertory::drive_mount_result &value) {
data["function_name"] = value.function_name;
data["mount_location"] = value.mount_location;
data["result"] = value.result;
}
static void from_json(const json &data,
repertory::drive_mount_result &value) {
data.at("function_name").get_to<std::string>(value.function_name);
data.at("mount_location").get_to<std::string>(value.mount_location);
data.at("result").get_to<std::string>(value.result);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_MOUNT_RESULT_HPP_

View File

@ -0,0 +1,70 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DRIVE_MOUNTED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_MOUNTED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)) {}
static constexpr const event_level level{event_level::info};
static constexpr const std::string_view name{"drive_mounted"};
std::string function_name;
std::string mount_location;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|location|{}", name, function_name,
mount_location);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::drive_mounted> {
static void to_json(json &data, const repertory::drive_mounted &value) {
data["function_name"] = value.function_name;
data["mount_location"] = value.mount_location;
}
static void from_json(const json &data, repertory::drive_mounted &value) {
data.at("function_name").get_to<std::string>(value.function_name);
data.at("mount_location").get_to<std::string>(value.mount_location);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_MOUNTED_HPP_

View File

@ -0,0 +1,67 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)) {}
static constexpr const event_level level{event_level::warn};
static constexpr const std::string_view name{"drive_stop_timed_out"};
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}", name, function_name);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::drive_stop_timed_out> {
static void to_json(json &data,
const repertory::drive_stop_timed_out &value) {
data["function_name"] = value.function_name;
}
static void from_json(const json &data,
repertory::drive_stop_timed_out &value) {
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_

View File

@ -0,0 +1,73 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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_EVENTS_TYPES_DRIVE_UNMOUNT_PENDING_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_UNMOUNT_PENDING_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
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_)) {}
static constexpr const event_level level{event_level::info};
static constexpr const std::string_view name{"drive_unmount_pending"};
std::string function_name;
std::string mount_location;
[[nodiscard]] auto get_event_level() const -> event_level override {
return level;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|location|{}", name, function_name,
mount_location);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::drive_unmount_pending> {
static void to_json(json &data,
const repertory::drive_unmount_pending &value) {
data["function_name"] = value.function_name;
data["mount_location"] = value.mount_location;
}
static void from_json(const json &data,
repertory::drive_unmount_pending &value) {
data.at("function_name").get_to<std::string>(value.function_name);
data.at("mount_location").get_to<std::string>(value.mount_location);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_UNMOUNT_PENDING_HPP_

Some files were not shown because too many files have changed in this diff Show More