Compare commits
622 Commits
v2.0.2-rc
...
13a55bff61
Author | SHA1 | Date | |
---|---|---|---|
13a55bff61 | |||
d6efc19ba8 | |||
517e603539 | |||
d144101a7e | |||
b84202a689 | |||
572351067c | |||
9a3d6e725e | |||
d6ac8cfeca | |||
e697363574 | |||
8cc6868480 | |||
37d393c1f9 | |||
ec8b7783f3 | |||
7b375eb912 | |||
ffdea97de3 | |||
7c02d79a5c | |||
46bbc4bf92 | |||
08104c97f7 | |||
8cf169849c | |||
67ac6a6c6e | |||
ef270887fc | |||
d61cb3f0f3 | |||
12d3fbe9a7 | |||
bf9d6157f5 | |||
c4d7868381 | |||
de0a88e45b | |||
fed4f40cfb | |||
d1b4aab952 | |||
072a5356b6 | |||
781278df06 | |||
42a81b1c8e | |||
3e6ed45562 | |||
366fe60e2f | |||
be30230422 | |||
a523d1ca66 | |||
62a75bcddd | |||
bd754a7ee8 | |||
ae98d199e7 | |||
95ff5dd5eb | |||
3f3e9b5735 | |||
82a48fa3b4 | |||
97ce74b798 | |||
91704df08d | |||
4add037dc7 | |||
79314a11b5 | |||
0ff87a0ac3 | |||
1aef67368b | |||
ba2a669be6 | |||
fd721c5dc4 | |||
34070bba89 | |||
1b1fc0fc09 | |||
44a1547d2e | |||
439f9cce3d | |||
9aecec2d96 | |||
26fffdd3e8 | |||
7bf69ec350 | |||
49f884bb68 | |||
a58fcc7f14 | |||
113b5e7258 | |||
5b337d4c65 | |||
0b80e82721 | |||
7e45fa9708 | |||
aa92f3d401 | |||
692c92b0df | |||
51cb2c0b9a | |||
6e52474953 | |||
35db1cd0c4 | |||
739a1103f0 | |||
bb8cbb49f5 | |||
3be29f5b73 | |||
d944569fb2 | |||
3ca27ec566 | |||
779bfc762e | |||
54828600a8 | |||
d5410b88a3 | |||
e86d9fd29b | |||
cbebcfae82 | |||
3dc16db278 | |||
e81227e5f7 | |||
fd83c263e1 | |||
9ca857c98e | |||
afcba6b086 | |||
ef50acc867 | |||
f12833f36c | |||
b26788819e | |||
f905de7c42 | |||
8466a8850f | |||
af8e2cddcb | |||
0089866142 | |||
ca892c7f11 | |||
2a33000ace | |||
bd8da9b987 | |||
5bd780ef07 | |||
25c445b889 | |||
ca4111ac77 | |||
868e8ae124 | |||
51358c7110 | |||
ad97741e1e | |||
5d281e0fd0 | |||
c1a1242398 | |||
5000215973 | |||
ceda21830f | |||
b80b7b482c | |||
8e41f71e70 | |||
72286c865f | |||
2d435457e6 | |||
cef1ff7067 | |||
393dc07de8 | |||
49f0425e56 | |||
7973e523c3 | |||
c4326520cd | |||
dfb9d78448 | |||
26714a836c | |||
59e2986080 | |||
65fc484fa4 | |||
253978bc5f | |||
4aad60f69d | |||
72f7aaf9e4 | |||
d12b5f7b05 | |||
a7239558bd | |||
9d3e4b8767 | |||
cbb99c7b47 | |||
dca0752189 | |||
760a1e4322 | |||
56bc78f63c | |||
60b89c5c08 | |||
fa0f648a0b | |||
5592c663a4 | |||
c847353baf | |||
a140f59acb | |||
b2eae73fb0 | |||
a34dc8f1f8 | |||
92e2937a6b | |||
47757f69bd | |||
b642294193 | |||
8075af364f | |||
3d7285063a | |||
232420621a | |||
a0432be819 | |||
468093227d | |||
32facdc2ff | |||
3a719272cb | |||
9ce4c5a494 | |||
15cc7b0b87 | |||
6d152181d3 | |||
97082fa42c | |||
becd137cf5 | |||
89fc0fb372 | |||
68d79c73cf | |||
d0e9ed4181 | |||
535d2f85ca | |||
5ec20fbcbd | |||
0225fb8e5d | |||
035f830b71 | |||
7a1fb4a790 | |||
4939b05ca7 | |||
2e1f0c8f5f | |||
d8ac596687 | |||
1f43ab3bcc | |||
ef9fbf775c | |||
d6ff728a4d | |||
f6ea8f077b | |||
3e96764fc4 | |||
45b21ae0af | |||
490e49406f | |||
36e7d06b39 | |||
b26b52fd2d | |||
b35041f1f3 | |||
bf7ba3991f | |||
30806c6ebd | |||
29af6e5b7c | |||
cde0e92591 | |||
85b28f7ee3 | |||
df24b99303 | |||
d659a5e04d | |||
99c0246720 | |||
c0dba76ecd | |||
e37a375c18 | |||
6718eb374d | |||
bba7f10703 | |||
df947db055 | |||
256e873e7b | |||
34bc3b759e | |||
853aa2784c | |||
4011ab8080 | |||
07eaad7226 | |||
c743d3c341 | |||
05a5645f4c | |||
7aa71fb202 | |||
6410faa5b4 | |||
a3e578240b | |||
dd492ff52d | |||
e7b576bc45 | |||
7fcc40d0e1 | |||
e6fc6093b2 | |||
73ee70a862 | |||
b647053fb9 | |||
d518e55a67 | |||
fcd38db2ef | |||
89cd8c8fd0 | |||
88c7e7f192 | |||
a00e77d554 | |||
05d5bd9fe5 | |||
e14e7e96c7 | |||
4b8ac300c8 | |||
ee9c5fffad | |||
55caf049b1 | |||
4bdaeaa30d | |||
7c58d9c569 | |||
d6b2c1d81e | |||
4a2acf99a7 | |||
3567941139 | |||
50e7fb612c | |||
03dd9ee579 | |||
2a3c6f3522 | |||
2e46f2fead | |||
b00b72d70f | |||
7dbaf9b8d9 | |||
6b463adbb9 | |||
cb819d7da6 | |||
841ba37841 | |||
7cfefbc512 | |||
9ebba7252c | |||
835c56330a | |||
3e5c70e6b4 | |||
95b88b6ac6 | |||
c1f39afaa3 | |||
1893f7204e | |||
4a062abfde | |||
fb26aa04b6 | |||
7c538b471d | |||
c4c1941fc8 | |||
0ce2be24a3 | |||
3cf60d0d26 | |||
7d33ee80d0 | |||
52ba2de51f | |||
a1b8b57d34 | |||
cf9e0a356c | |||
e66b783df8 | |||
b695200123 | |||
a383fb405e | |||
1cebaf83e1 | |||
4976825bd6 | |||
098d172f40 | |||
f4a3c52428 | |||
2d60b637ec | |||
79b16d9a34 | |||
d69f2fd321 | |||
4015c1bb6e | |||
9f76f20ea8 | |||
b399ff3291 | |||
4fafc17b90 | |||
f1bb88624b | |||
f950e3192f | |||
bef2f078e0 | |||
218053a2be | |||
baca904079 | |||
b5175cb82b | |||
39888a1ebc | |||
ffea22c71b | |||
dd15bb2205 | |||
4b53b5544f | |||
24ca2d3531 | |||
5587e3430b | |||
0c36669fef | |||
bbce86cb9d | |||
ed3a45bfc6 | |||
144fd59c1c | |||
bdc54d7115 | |||
aa04371663 | |||
78ef412516 | |||
28f7f5cb14 | |||
624b92bc97 | |||
ca799298f4 | |||
42b67a7b61 | |||
4de4386142 | |||
509eeca760 | |||
1cb9663776 | |||
26667fdcd6 | |||
681a3eec53 | |||
2a5df890f7 | |||
ae0059591c | |||
8655becf1e | |||
2a3a0aa689 | |||
ce417ec7c8 | |||
4e848a998e | |||
d89f35775e | |||
88ebf72003 | |||
9437b175a2 | |||
302d73a078 | |||
ba7c36e30e | |||
b4da43c87f | |||
f5e078ea3d | |||
8aba39c955 | |||
68a5f90715 | |||
f3dfadddfa | |||
f1ec1fd4a6 | |||
cf59db9cee | |||
e21fbe84ba | |||
1e4d675f76 | |||
e02fe870e9 | |||
9ef9250c18 | |||
2e4b9d3787 | |||
fd2b3c3239 | |||
6640394bd3 | |||
84cc726c4f | |||
5d99d21915 | |||
3b8636544a | |||
14ce60ab65 | |||
7506431b34 | |||
8621209eb3 | |||
d1fe317fb9 | |||
a5c47d3f22 | |||
267c272ce5 | |||
7a8ae32b85 | |||
921d404a5a | |||
de6a7beb5e | |||
5a928208fd | |||
92fc163341 | |||
ca1e03f3ea | |||
de8c3ad603 | |||
f7d56bdd48 | |||
afc13b45f4 | |||
11d2c3c69e | |||
356521e176 | |||
468668e518 | |||
e53dec7bab | |||
26cd6de110 | |||
d1157ca261 | |||
0d49b49482 | |||
753820bd81 | |||
2a98e44a5c | |||
9650d3f56b | |||
aff308f67d | |||
be76d663b5 | |||
160863561f | |||
de02fdb812 | |||
1dda98e337 | |||
ccc6afdfa4 | |||
6b166551af | |||
90694f816f | |||
51636fbac3 | |||
3c7aa417a9 | |||
04d560739d | |||
2c1842f06c | |||
aba487277c | |||
1b95d5dfed | |||
7590fc4f45 | |||
a409408ac0 | |||
b121c9778f | |||
d452761ff9 | |||
dbc5725779 | |||
8b6536c55b | |||
c7318b0383 | |||
26fa85e421 | |||
939742a991 | |||
6ab7386a79 | |||
a750cdc3cb | |||
2f8af0fb08 | |||
7a9802ccb7 | |||
d356d04bf5 | |||
c99c4988ff | |||
6c564eb98b | |||
786d8634cf | |||
70b5204a9f | |||
1d70309a16 | |||
b2aba8c447 | |||
8757b47b35 | |||
b1a7632536 | |||
97c73d5358 | |||
bb3f05aef1 | |||
2001ffc27c | |||
bd2dd4035e | |||
7eb793f577 | |||
b05cedb509 | |||
cd484aa7bb | |||
fbfb528adc | |||
d9cba7f4cc | |||
7d5c5e18c6 | |||
2c0935a771 | |||
5312797b97 | |||
801af6b799 | |||
b42379b519 | |||
8b328b92b1 | |||
2e6ecf8ddb | |||
12c7c48b20 | |||
732a42a073 | |||
5638d5c010 | |||
6a984ac84c | |||
c1eb6b94ed | |||
85135b9267 | |||
670c5bac17 | |||
2dab1426b4 | |||
43004b19c3 | |||
4044d95aaa | |||
c6024c06ce | |||
e56bcb6489 | |||
d9e0164080 | |||
b588cd645e | |||
2c163d7219 | |||
39c53fe903 | |||
7b12d8f9e9 | |||
4649f66c00 | |||
9648abf4b9 | |||
cc1246d0f5 | |||
726aa43a95 | |||
224f983ca8 | |||
f962884341 | |||
6f35cc8bfa | |||
c08c9bc216 | |||
239652be7c | |||
68c9ec0f82 | |||
da07122997 | |||
5fb66dc6ee | |||
0c414fc8a6 | |||
097507a2d9 | |||
466b3fcead | |||
81dc6d1269 | |||
b6c020d35d | |||
dfbe97988f | |||
cd36679a1c | |||
4d555bce96 | |||
d96c6012c5 | |||
15793e714d | |||
437cb94dda | |||
544765e408 | |||
472b1f0da1 | |||
867b2eee40 | |||
5a30b15d1e | |||
0f2c507c30 | |||
c545916332 | |||
ac81f5f624 | |||
50ae7ab558 | |||
a5e29ed745 | |||
6d29170342 | |||
410314022f | |||
815e00d389 | |||
fbf5455f89 | |||
8925704555 | |||
462365dc97 | |||
e73dd52973 | |||
881eec4e02 | |||
bcdfc73767 | |||
0520aa3d40 | |||
c562d17b78 | |||
aee68520b3 | |||
88d8bf63f5 | |||
303887ea37 | |||
51d3d33175 | |||
cdb5ea279d | |||
311e1b318a | |||
31c5b6f1db | |||
a024f81e5d | |||
4089fca87c | |||
99533a9687 | |||
d175a38ad1 | |||
28e918be18 | |||
b4403ff959 | |||
8c548bad92 | |||
6ecad9af72 | |||
df73f9a18f | |||
9b453327a8 | |||
071552ffd5 | |||
33a0b4b295 | |||
21bcd0780c | |||
f6cdf2914c | |||
7698a62c1f | |||
2ae22cdb30 | |||
7705432820 | |||
f150832676 | |||
80c9375d65 | |||
48ddff9e85 | |||
6f64fe02d5 | |||
61ab4d8d58 | |||
3bb962a266 | |||
c286dc4f5c | |||
9d36ded2b3 | |||
71686405e0 | |||
34c4a9c508 | |||
effafd3e91 | |||
5a61bdf2b0 | |||
d21fcfd1c6 | |||
fff9a27362 | |||
ad7872a0e3 | |||
f3ea2ccc21 | |||
e959a9e795 | |||
3fe5eac56d | |||
67191be78d | |||
00cfb67b64 | |||
35aa8f5a94 | |||
f44972b8b3 | |||
94675a3011 | |||
7112fbee7e | |||
ff13633962 | |||
cb93e34de0 | |||
883968f53e | |||
d6d4b579c9 | |||
0e83d84360 | |||
63a6b3bdba | |||
aafa7e112a | |||
804eb7aa5a | |||
eeba641732 | |||
932ea6cb1d | |||
dd4724e374 | |||
e652c9956e | |||
d11767776e | |||
daefa58c0c | |||
7fe7299e7c | |||
0af9c6e8b0 | |||
b9c2113d43 | |||
4fd23de9b6 | |||
3b372ebe86 | |||
d14d149a3b | |||
44acf7dace | |||
da7efdb1a8 | |||
444f39f9ff | |||
fd9c26f016 | |||
7ef9f5cd65 | |||
d3321b3c57 | |||
bbe546008f | |||
5ec91e2d20 | |||
fbe4df0251 | |||
e5c690eb89 | |||
aeedd114a6 | |||
dfa5e0e005 | |||
5911d370e5 | |||
baf769c462 | |||
33e8e0890b | |||
e2e82edefb | |||
da1b5c6953 | |||
629725e262 | |||
6ba4c0091b | |||
99d5261aab | |||
97487cf0c4 | |||
8436f2e2bb | |||
310e436163 | |||
b64477fd7e | |||
782da43114 | |||
37854b693b | |||
7360b72c7b | |||
6f68f268c0 | |||
983587aeb7 | |||
ee415d2e4a | |||
0c075d7fe4 | |||
eec3653c6b | |||
5ac2a24611 | |||
144683d7b3 | |||
9c917a9119 | |||
dc48b84191 | |||
8555d31ddf | |||
cb0dde2a80 | |||
5f5b1f751b | |||
24c5dad929 | |||
f0046fcd57 | |||
3c3e415175 | |||
00d3355f43 | |||
907a14faff | |||
4348e89f99 | |||
7a24cc54f8 | |||
80f6e3c272 | |||
edb1297c4a | |||
1ee157f943 | |||
1b2981b06e | |||
7203fefd33 | |||
d808b2dd19 | |||
ee34a1e361 | |||
1766f91697 | |||
b3aa28d085 | |||
a605d7af11 | |||
19b1a33c48 | |||
04aa511448 | |||
8dc3d4466b | |||
0716a58ff0 | |||
60052081b4 | |||
f11d49b264 | |||
103dae6d08 | |||
821ed7b25e | |||
87f83b6f30 | |||
ace81d797e | |||
57ca2c7c6d | |||
8360d9e045 | |||
560ffbbb6a | |||
72314606f3 | |||
db009b69dd | |||
3ed99dc0ce | |||
762a7c99d5 | |||
4e62156b70 | |||
cc49536755 | |||
54b844dc3b | |||
1e8ba13f66 | |||
93011cee9c | |||
a474a5c73c | |||
17b98ca99d | |||
281eedb71e | |||
1ee533591c | |||
b87e1df140 | |||
f88239a13e | |||
68476cbc00 | |||
f2c1f64f02 | |||
a7209184c8 | |||
ba59e29499 | |||
f94196d865 | |||
bb5a9f9737 | |||
4bc5cf7c64 | |||
639d14452b | |||
e7413fb741 | |||
c0e720498d | |||
383c3b4be6 | |||
e9b202f5c8 | |||
bc3005a6a4 | |||
8cf19e0594 | |||
b137b57dbc | |||
5dff8927da | |||
197e79dd07 | |||
6262aca761 | |||
c156ae704b | |||
a67979ec40 | |||
54bfc11620 | |||
d33c2cd3a2 | |||
3a5f428fb6 | |||
0331152569 | |||
1b7e854f5f | |||
12a945d863 |
@ -23,7 +23,6 @@ cppflags
|
||||
cpphttplib
|
||||
cpptrace
|
||||
cppvsdbg
|
||||
create_notraverse
|
||||
crypto_aead_xchacha20poly1305_ietf_npubbytes
|
||||
cstdint
|
||||
cxxflags
|
||||
@ -31,7 +30,6 @@ cxxstd
|
||||
d_largefile64_source
|
||||
d_largefile_source
|
||||
d_ndebug
|
||||
dacl_security_information
|
||||
dbackward_shared
|
||||
dbghelp
|
||||
dboost_root
|
||||
@ -96,7 +94,6 @@ expect_streq
|
||||
fallocate_impl
|
||||
fext
|
||||
fgetattr
|
||||
fgetattr_impl
|
||||
filebase
|
||||
flac_version
|
||||
flag_nopath
|
||||
@ -120,7 +117,6 @@ icui18n
|
||||
icuuc
|
||||
iostreams
|
||||
iphlpapi
|
||||
jthread
|
||||
libbitcoin
|
||||
libbitcoinsystem
|
||||
libcurl
|
||||
@ -139,8 +135,6 @@ libuuid
|
||||
libuuid_include_dirs
|
||||
libvlc
|
||||
linkflags
|
||||
lptr
|
||||
lpwstr
|
||||
markdownlint
|
||||
mbig
|
||||
msvc
|
||||
@ -159,9 +153,7 @@ oleaut32
|
||||
openal_version
|
||||
openssldir
|
||||
pkgconfig
|
||||
plarge_integer
|
||||
plex
|
||||
println
|
||||
project_enable_fontconfig
|
||||
project_enable_gtkmm
|
||||
project_enable_libdsm
|
||||
@ -173,15 +165,11 @@ pugixml_project
|
||||
puint32
|
||||
pvoid
|
||||
pwstr
|
||||
rdrw
|
||||
remote_winfsp
|
||||
renterd
|
||||
richtext
|
||||
rocksdb_library
|
||||
rpcrt4
|
||||
s_igid
|
||||
s_isvtx
|
||||
s_iuid
|
||||
sddl_revision_1
|
||||
secp256k1
|
||||
secur32
|
||||
@ -230,4 +218,4 @@ wsign-conversion
|
||||
wunused
|
||||
wuseless
|
||||
wxwidgets_version
|
||||
xattr
|
||||
xattr
|
||||
|
@ -6,7 +6,7 @@ pipeline {
|
||||
environment {
|
||||
DEVELOPER_PRIVATE_KEY = "/.ci/repertory/cert/developer.priv"
|
||||
DEVELOPER_PUBLIC_KEY = "/.ci/repertory/cert/developer.pub"
|
||||
PROJECT_TEST_CONFIG_DIR = "/.ci/repertory/test_config"
|
||||
PROJECT_TEST_DIR = "/.ci/repertory/test"
|
||||
}
|
||||
|
||||
options {
|
||||
|
7
.nvimrc
7
.nvimrc
@ -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("./dist/debug/shared/linux/x86_64/repertory/")
|
||||
local cwd = gpath.create_path("./build")
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "Mount",
|
||||
type = type,
|
||||
request = "launch",
|
||||
program = function()
|
||||
return gpath.create_path(cwd, "bin/repertory")
|
||||
return gpath.create_path(cwd, "repertory")
|
||||
end,
|
||||
cwd = cwd,
|
||||
stopAtEntry = true,
|
||||
@ -36,9 +36,8 @@ if vim.env.NV_DARCULA_ENABLE_DAP then
|
||||
type = type,
|
||||
request = "launch",
|
||||
program = function()
|
||||
return gpath.create_path(cwd, "bin/repertory_test")
|
||||
return gpath.create_path(cwd, "repertory_tests")
|
||||
end,
|
||||
args={"--gtest_filter=utils_db*"},
|
||||
cwd = cwd,
|
||||
stopAtEntry = true,
|
||||
externalConsole=externalConsole,
|
||||
|
16
CHANGELOG.md
16
CHANGELOG.md
@ -2,34 +2,22 @@
|
||||
|
||||
## 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
|
||||
* \#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
|
||||
* MSYS2 is required for building Windows binaries 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
|
||||
|
||||
|
@ -148,7 +148,6 @@ 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}
|
||||
|
64
README.md
64
README.md
@ -7,6 +7,7 @@ on Windows.
|
||||
|
||||
* 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)
|
||||
@ -28,69 +29,26 @@ on Windows.
|
||||
* ~~OS X Mojave and above~~
|
||||
* Windows 64-bit 10, 11
|
||||
|
||||
## Usage
|
||||
|
||||
### Notable Options
|
||||
|
||||
* `-dc`
|
||||
* Display mount configuration.
|
||||
* For Sia, `--name` is optional
|
||||
* For S3, the `-s3` option is required along with `--name`
|
||||
* `--help`
|
||||
* Display all mount utility options.
|
||||
* `--name, -na [name]`
|
||||
* 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.
|
||||
* `-set SiaConfig.Bucket`
|
||||
* Set Sia bucket name for the mount.
|
||||
* Can be used in combination with `--name` to target a unique configuration.
|
||||
* `-set S3Config.Bucket`
|
||||
* S3 bucket name for the mount.
|
||||
* Must be used in combination with `--name` to target a unique configuration.
|
||||
* Must be used in combination with `-s3`.
|
||||
|
||||
### Sia
|
||||
|
||||
* Linux
|
||||
* `repertory /mnt/location`
|
||||
* `repertory --name default /mnt/location`
|
||||
* Windows
|
||||
* `repertory.exe t:`
|
||||
* `repertory.exe --name default t:`
|
||||
|
||||
### S3
|
||||
|
||||
* Linux
|
||||
* `repertory --name storj -s3 /mnt/location`
|
||||
* Windows
|
||||
* `repertory.exe --name storj -s3 t:`
|
||||
|
||||
## Compiling
|
||||
|
||||
* Successful compilation will result in all required files being placed in the `dist/` directory
|
||||
* Linux
|
||||
* Ensure `docker` is installed
|
||||
* For x86_64:
|
||||
* RelWithDebInfo: `scripts/make_unix.sh`
|
||||
* Release: `scripts/make_unix.sh x86_64 Release`
|
||||
* Debug: `scripts/make_unix.sh x86_64 Debug`
|
||||
* Release: `scripts/make_unix.sh x86_64`
|
||||
* Debug: `scripts/make_unix.sh x86_64 debug`
|
||||
* For aarch64:
|
||||
* RelWithDebInfo: `scripts/make_unix.sh aarch64`
|
||||
* Release: `scripts/make_unix.sh aarch64 Release`
|
||||
* Debug: `scripts/make_unix.sh aarch64 Debug`
|
||||
* Release: `scripts/make_unix.sh aarch64`
|
||||
* Debug: `scripts/make_unix.sh aarch64 debug`
|
||||
* Windows
|
||||
* OFFICIAL: Cross-compiling on Linux
|
||||
* RECOMMENDED: Cross-compiling on Linux
|
||||
* Ensure `docker` is installed
|
||||
* RelWithDebInfo: `scripts/make_win32.sh`
|
||||
* Release: `scripts/make_win32.sh x86_64 Release`
|
||||
* Debug: `scripts/make_win32.sh x86_64 Debug`
|
||||
* UNOFFICIAL: Compiling on Windows
|
||||
* Release: `scripts/make_win32.sh`
|
||||
* Debug: `scripts/make_win32.sh debug`
|
||||
* Compiling on Windows
|
||||
* Ensure latest [MSYS2](https://www.msys2.org/) is installed
|
||||
* RelWithDebInfo: `scripts\make_win32.cmd`
|
||||
* Release: `scripts\make_win32.cmd x86_64 Release`
|
||||
* Debug: `scripts\make_win32.cmd x86_64 Debug`
|
||||
* Release: `scripts/make_win32.cmd`
|
||||
* Debug: `scripts/make_win32.cmd debug`
|
||||
|
||||
## Credits
|
||||
|
||||
|
@ -1,20 +1,41 @@
|
||||
set(BINUTILS_HASH ae9a5789e23459e59606e6714723f2d3ffc31c03174191ef0d015bdf06007450)
|
||||
set(BOOST_HASH f55c340aa49763b1925ccf02b2e83f35fdcf634c9d5164a2acb87540173c741d)
|
||||
set(BOOST2_HASH 7bd7ddceec1a1dfdcbdb3e609b60d01739c38390a5f956385a12f3122049f0ca)
|
||||
set(CPP_HTTPLIB_HASH 405abd8170f2a446fc8612ac635d0db5947c0d2e156e32603403a4496255ff00)
|
||||
set(CURL_HASH 5a231145114589491fc52da118f9c7ef8abee885d1cb1ced99c7290e9a352f07)
|
||||
set(EXPAT_HASH 372b18f6527d162fa9658f1c74d22a37429b82d822f5a1e1fc7e00f6045a06a2)
|
||||
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(GCC_HASH 7d376d445f93126dc545e2c0086d0f647c3094aae081cdb78f42ce2bc25e7293)
|
||||
set(GTEST_HASH 7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926)
|
||||
set(ICU_HASH 925e6b4b8cf8856e0ac214f6f34e30dee63b7bb7a50460ab4603950eff48f89e)
|
||||
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(OPENSSL_HASH e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf)
|
||||
set(NANA_HASH 56f7b1ed006c750fccf8ef15ab1e83f96751f2dfdcb68d93e5f712a6c9b58bcb)
|
||||
set(NUSPELL_HASH 5d4baa1daf833a18dc06ae0af0571d9574cc849d47daff6b9ce11dac0a5ded6a)
|
||||
set(OGG_HASH 0eb4b4b9420a0f51db142ba3f9c64b333f826532dc0f48c6410ae51f4799b664)
|
||||
set(OPENAL_HASH dfddf3a1f61059853c625b7bb03de8433b455f2f79f89548cbcbd5edca3d4a4a)
|
||||
set(OPENSSL_HASH 777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e)
|
||||
set(PKG_CONFIG_HASH 6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591)
|
||||
set(PUGIXML_HASH 2f10e276870c64b1db6809050a75e11a897a8d7456c4be5c6b2e35a11168a015)
|
||||
set(ROCKSDB_HASH 9b810c81731835fda0d4bbdb51d3199d901fa4395733ab63752d297da84c5a47)
|
||||
set(SPDLOG_HASH 9962648c9b4f1a7bbc76fd8d9172555bad1871fdb14ff4f842ef87949682caa5)
|
||||
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(STDUUID_HASH b1176597e789531c38481acbbed2a6894ad419aab0979c10410d59eb0ebf40d3)
|
||||
set(VORBIS_HASH 270c76933d0934e42c5ee0a54a36280e2d87af1de3cc3e584806357e237afd13)
|
||||
set(WXWIDGETS_HASH 0ad86a3ad3e2e519b6a705248fc9226e3a09bbf069c6c692a02acf7c2d1c6b51)
|
||||
set(ZLIB_HASH 17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c)
|
||||
|
@ -17,7 +17,6 @@ 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)
|
||||
|
@ -1,34 +0,0 @@
|
||||
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 |
|
||||
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()
|
@ -6,7 +6,6 @@ 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)
|
||||
|
@ -3,13 +3,13 @@ set(BOOST2_MAJOR_VERSION 1)
|
||||
set(BOOST2_MINOR_VERSION 76)
|
||||
set(BOOST2_PATCH_VERSION 0)
|
||||
set(BOOST_MAJOR_VERSION 1)
|
||||
set(BOOST_MINOR_VERSION 87)
|
||||
set(BOOST_MINOR_VERSION 85)
|
||||
set(BOOST_PATCH_VERSION 0)
|
||||
set(CPP_HTTPLIB_VERSION 0.18.1)
|
||||
set(CURL2_VERSION 8_11_0)
|
||||
set(CURL_VERSION 8.11.0)
|
||||
set(EXPAT2_VERSION 2_6_4)
|
||||
set(EXPAT_VERSION 2.6.4)
|
||||
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(GCC_VERSION 14.2.0)
|
||||
set(GTEST_VERSION 1.15.2)
|
||||
set(ICU_VERSION 75-1)
|
||||
@ -17,11 +17,10 @@ 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.4.0)
|
||||
set(OPENSSL_VERSION 3.3.1)
|
||||
set(PKG_CONFIG_VERSION 0.29.2)
|
||||
set(PUGIXML_VERSION 1.14)
|
||||
set(ROCKSDB_VERSION 9.7.4)
|
||||
set(SPDLOG_VERSION 1.15.0)
|
||||
set(SPDLOG_VERSION 1.14.1)
|
||||
set(SQLITE2_VERSION 3.46.1)
|
||||
set(SQLITE_VERSION 3460100)
|
||||
set(STDUUID_VERSION 1.2.3)
|
||||
|
@ -30,7 +30,6 @@ 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
|
||||
|
@ -572,8 +572,8 @@ RUN if [ -f "/3rd_party/flac-${MY_FLAC_VERSION}.tar.gz" ]; then \
|
||||
&& cd build \
|
||||
&& cmake .. \
|
||||
-DBUILD_DOCS=OFF \
|
||||
-DBUILD_EXAMPLES=OFF \
|
||||
-DBUILD_PROGRAMS=OFF \
|
||||
-DBUILD_EXAMPLES=ON \
|
||||
-DBUILD_PROGRAMS=ON \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
-DBUILD_STATIC_LIBS=ON \
|
||||
-DBUILD_TESTING=OFF \
|
||||
@ -604,7 +604,6 @@ 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 \
|
||||
|
@ -3,8 +3,8 @@
|
||||
CURRENT_DIR=$(dirname "$0")
|
||||
CURRENT_DIR=$(realpath ${CURRENT_DIR})
|
||||
|
||||
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_BUILD_DIR}/build/test_config/
|
||||
|
||||
rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_input/ \
|
||||
${PROJECT_DIST_DIR}/test_input/
|
||||
rsync -av --progress ${CURRENT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_test/test_config/ \
|
||||
${PROJECT_DIST_DIR}/test_config/
|
||||
|
@ -19,12 +19,13 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_APP_CONFIG_HPP_
|
||||
#define REPERTORY_INCLUDE_APP_CONFIG_HPP_
|
||||
#ifndef INCLUDE_APP_CONFIG_HPP_
|
||||
#define INCLUDE_APP_CONFIG_HPP_
|
||||
|
||||
#include "events/event.hpp"
|
||||
#include "types/remote.hpp"
|
||||
#include "events/event_system.hpp"
|
||||
#include "events/events.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/error_utils.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class app_config final {
|
||||
@ -39,7 +40,7 @@ public:
|
||||
default_data_directory(const provider_type &prov) -> std::string;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
default_remote_api_port(const provider_type &prov) -> std::uint16_t;
|
||||
default_remote_port(const provider_type &prov) -> std::uint16_t;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
default_rpc_port(const provider_type &prov) -> std::uint16_t;
|
||||
@ -53,206 +54,405 @@ public:
|
||||
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_;
|
||||
atomic<std::string> api_auth_;
|
||||
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)
|
||||
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<std::uint16_t> orphaned_file_retention_days_;
|
||||
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_;
|
||||
std::string api_auth_;
|
||||
std::uint16_t api_port_;
|
||||
std::string api_user_;
|
||||
bool config_changed_;
|
||||
std::string data_directory_;
|
||||
atomic<encrypt_config> encrypt_config_;
|
||||
atomic<host_config> host_config_;
|
||||
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_;
|
||||
#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::string cache_directory_;
|
||||
host_config hc_;
|
||||
s3_config s3_config_;
|
||||
sia_config sia_config_{"default"};
|
||||
std::uint64_t version_{REPERTORY_CONFIG_VERSION};
|
||||
std::string log_directory_;
|
||||
mutable std::recursive_mutex read_write_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};
|
||||
mutable std::recursive_mutex remote_mount_mutex_;
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_api_auth() const -> std::string;
|
||||
[[nodiscard]] auto get_api_auth() const -> std::string { return api_auth_; }
|
||||
|
||||
[[nodiscard]] auto get_api_port() const -> std::uint16_t;
|
||||
[[nodiscard]] auto get_api_port() const -> std::uint16_t { return api_port_; }
|
||||
|
||||
[[nodiscard]] auto get_api_user() const -> std::string;
|
||||
[[nodiscard]] auto get_api_user() const -> std::string { return api_user_; }
|
||||
|
||||
[[nodiscard]] auto get_cache_directory() 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_config_file_path() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto get_database_type() const -> database_type;
|
||||
[[nodiscard]] auto get_data_directory() const -> std::string {
|
||||
return data_directory_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_data_directory() const -> std::string;
|
||||
[[nodiscard]] auto get_enable_chunk_download_timeout() const -> bool {
|
||||
return enable_chunk_downloader_timeout_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_download_timeout_secs() const -> std::uint8_t;
|
||||
[[nodiscard]] auto get_enable_comm_duration_events() const -> bool {
|
||||
return enable_comm_duration_events_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_enable_download_timeout() const -> bool;
|
||||
[[nodiscard]] auto get_enable_drive_events() const -> bool {
|
||||
return enable_drive_events_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_enable_drive_events() const -> bool;
|
||||
|
||||
[[nodiscard]] auto get_encrypt_config() const -> encrypt_config;
|
||||
[[nodiscard]] auto get_encrypt_config() const -> encrypt_config {
|
||||
return encrypt_config_;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
[[nodiscard]] auto get_enable_mount_manager() const -> bool;
|
||||
#endif // defined(_WIN32)
|
||||
[[nodiscard]] auto get_enable_mount_manager() const -> bool {
|
||||
return enable_mount_manager_;
|
||||
}
|
||||
#endif
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level;
|
||||
[[nodiscard]] auto get_enable_max_cache_size() const -> bool {
|
||||
return enable_max_cache_size_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_eviction_delay_mins() const -> std::uint32_t;
|
||||
[[nodiscard]] auto get_enable_remote_mount() const -> bool {
|
||||
return enable_remote_mount_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_eviction_uses_accessed_time() const -> bool;
|
||||
[[nodiscard]] auto get_event_level() const -> event_level {
|
||||
return event_level_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_high_frequency_interval_secs() const -> std::uint16_t;
|
||||
[[nodiscard]] auto get_eviction_delay_mins() const -> std::uint32_t {
|
||||
return eviction_delay_mins_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_host_config() const -> host_config;
|
||||
[[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_json() const -> json;
|
||||
|
||||
[[nodiscard]] auto get_log_directory() const -> std::string;
|
||||
[[nodiscard]] auto get_log_directory() const -> std::string {
|
||||
return log_directory_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_low_frequency_interval_secs() const -> std::uint16_t;
|
||||
[[nodiscard]] auto get_low_frequency_interval_secs() const -> std::uint32_t {
|
||||
return std::max(1U, low_freq_interval_secs_);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_max_cache_size_bytes() const -> std::uint64_t;
|
||||
|
||||
[[nodiscard]] auto get_max_upload_count() const -> std::uint8_t;
|
||||
[[nodiscard]] auto get_max_upload_count() const -> std::uint8_t {
|
||||
return std::max(std::uint8_t(1U), max_upload_count_);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_med_frequency_interval_secs() const -> std::uint16_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_online_check_retry_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_orphaned_file_retention_days() 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_version() const -> std::uint64_t;
|
||||
[[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_; }
|
||||
|
||||
void save();
|
||||
|
||||
void set_api_auth(const std::string &value);
|
||||
void set_api_auth(const std::string &api_auth) {
|
||||
set_value(api_auth_, api_auth);
|
||||
}
|
||||
|
||||
void set_api_port(std::uint16_t value);
|
||||
void set_api_port(std::uint16_t api_port) { set_value(api_port_, api_port); }
|
||||
|
||||
void set_api_user(const std::string &value);
|
||||
void set_api_user(const std::string &api_user) {
|
||||
set_value(api_user_, api_user);
|
||||
}
|
||||
|
||||
void set_download_timeout_secs(std::uint8_t 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_database_type(const database_type &value);
|
||||
void
|
||||
set_enable_chunk_downloader_timeout(bool enable_chunk_downloader_timeout) {
|
||||
set_value(enable_chunk_downloader_timeout_,
|
||||
enable_chunk_downloader_timeout);
|
||||
}
|
||||
|
||||
void set_enable_download_timeout(bool 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_drive_events(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);
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
void set_enable_mount_manager(bool value);
|
||||
#endif // defined(_WIN32)
|
||||
void set_enable_mount_manager(bool enable_mount_manager) {
|
||||
set_value(enable_mount_manager_, enable_mount_manager);
|
||||
}
|
||||
#endif
|
||||
|
||||
void set_event_level(const event_level &value);
|
||||
void set_enable_remote_mount(bool enable_remote_mount);
|
||||
|
||||
void set_encrypt_config(encrypt_config 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_eviction_delay_mins(std::uint32_t value);
|
||||
void set_eviction_delay_mins(std::uint32_t eviction_delay_mins) {
|
||||
set_value(eviction_delay_mins_, eviction_delay_mins);
|
||||
}
|
||||
|
||||
void set_eviction_uses_accessed_time(bool value);
|
||||
void set_eviction_uses_accessed_time(bool eviction_uses_accessed_time) {
|
||||
set_value(eviction_uses_accessed_time_, eviction_uses_accessed_time);
|
||||
}
|
||||
|
||||
void set_high_frequency_interval_secs(std::uint16_t 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_host_config(host_config value);
|
||||
#if defined(PROJECT_TESTING)
|
||||
void set_host_config(host_config hc) {
|
||||
config_changed_ = true;
|
||||
hc_ = std::move(hc);
|
||||
save();
|
||||
}
|
||||
|
||||
void set_low_frequency_interval_secs(std::uint16_t value);
|
||||
void set_s3_config(s3_config s3) {
|
||||
config_changed_ = true;
|
||||
s3_config_ = std::move(s3);
|
||||
save();
|
||||
}
|
||||
#endif
|
||||
|
||||
void set_max_cache_size_bytes(std::uint64_t value);
|
||||
void set_is_remote_mount(bool is_remote_mount);
|
||||
|
||||
void set_max_upload_count(std::uint8_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_med_frequency_interval_secs(std::uint16_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_online_check_retry_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_orphaned_file_retention_days(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_task_wait_ms(std::uint16_t value);
|
||||
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);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto set_value_by_name(const std::string &name,
|
||||
const std::string &value) -> std::string;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_APP_CONFIG_HPP_
|
||||
#endif // INCLUDE_APP_CONFIG_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_CURL_COMM_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_CURL_COMM_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_CURL_COMM_HPP_
|
||||
#define INCLUDE_COMM_CURL_CURL_COMM_HPP_
|
||||
|
||||
#include "comm/curl/multi_request.hpp"
|
||||
#include "comm/i_http_comm.hpp"
|
||||
@ -238,4 +238,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_COMM_CURL_CURL_COMM_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_CURL_COMM_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
|
||||
#define INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
@ -41,4 +41,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_MULTI_REQUEST_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_DELETE_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_DELETE_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_DELETE_HPP_
|
||||
#define INCLUDE_COMM_CURL_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 // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_DELETE_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_DELETE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_GET_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_GET_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_GET_HPP_
|
||||
#define INCLUDE_COMM_CURL_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 // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_GET_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_GET_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_HEAD_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_HEAD_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_HEAD_HPP_
|
||||
#define INCLUDE_COMM_CURL_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 // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_HEAD_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_HEAD_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_POST_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_POST_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_POST_HPP_
|
||||
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_POST_HPP_
|
||||
|
||||
#include "comm/curl/requests/http_request_base.hpp"
|
||||
|
||||
@ -36,8 +36,9 @@ struct http_post final : http_request_base {
|
||||
|
||||
std::optional<nlohmann::json> json;
|
||||
|
||||
[[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;
|
||||
|
||||
private:
|
||||
mutable curl_slist *headers{nullptr};
|
||||
@ -45,4 +46,4 @@ private:
|
||||
};
|
||||
} // namespace repertory::curl::requests
|
||||
|
||||
#endif // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_POST_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_POST_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
|
||||
#define INCLUDE_COMM_CURL_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 // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_PUT_FILE_HPP_
|
||||
|
@ -19,14 +19,16 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
|
||||
#ifndef INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
|
||||
#define INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/file.hpp"
|
||||
|
||||
namespace repertory::curl::requests {
|
||||
using curl_response_callback =
|
||||
using read_callback = size_t (*)(char *, size_t, size_t, void *);
|
||||
|
||||
using response_callback =
|
||||
std::function<void(const data_buffer &data, long response_code)>;
|
||||
|
||||
struct read_file_info final {
|
||||
@ -35,8 +37,19 @@ struct read_file_info final {
|
||||
std::uint64_t offset{};
|
||||
};
|
||||
|
||||
[[nodiscard]] auto curl_file_reader(char *buffer, size_t size, size_t nitems,
|
||||
void *instream) -> size_t;
|
||||
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;
|
||||
});
|
||||
|
||||
struct http_request_base {
|
||||
http_request_base() = default;
|
||||
@ -55,16 +68,15 @@ struct http_request_base {
|
||||
std::string path{};
|
||||
http_query_parameters query{};
|
||||
std::optional<http_range> range{};
|
||||
std::optional<curl_response_callback> response_handler;
|
||||
std::optional<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 // REPERTORY_INCLUDE_COMM_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
|
||||
#endif // INCLUDE_COMM_CURL_CURL_REQUESTS_HTTP_REQUEST_BASE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_I_HTTP_COMM_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_I_HTTP_COMM_HPP_
|
||||
#ifndef INCLUDE_COMM_I_HTTP_COMM_HPP_
|
||||
#define INCLUDE_COMM_I_HTTP_COMM_HPP_
|
||||
|
||||
#include "comm/curl/requests/http_delete.hpp"
|
||||
#include "comm/curl/requests/http_get.hpp"
|
||||
@ -40,23 +40,26 @@ 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 // REPERTORY_INCLUDE_COMM_I_HTTP_COMM_HPP_
|
||||
#endif // INCLUDE_COMM_I_HTTP_COMM_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
|
||||
#ifndef INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
|
||||
#define INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
|
||||
|
||||
#include "comm/packet/packet.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -107,4 +107,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
|
||||
#endif // INCLUDE_COMM_PACKET_CLIENT_POOL_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_PACKET_PACKET_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_HPP_
|
||||
#ifndef INCLUDE_COMM_PACKET_PACKET_HPP_
|
||||
#define 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_.at(decode_offset_)
|
||||
return (decode_offset_ < buffer_.size()) ? &buffer_[decode_offset_]
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto current_pointer() const -> const unsigned char * {
|
||||
return (decode_offset_ < buffer_.size()) ? &buffer_.at(decode_offset_)
|
||||
return (decode_offset_ < buffer_.size()) ? &buffer_[decode_offset_]
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ public:
|
||||
return static_cast<std::uint32_t>(buffer_.size());
|
||||
}
|
||||
|
||||
void to_buffer(data_buffer &buffer);
|
||||
void transfer_into(data_buffer &buffer);
|
||||
|
||||
public:
|
||||
auto operator=(const data_buffer &buffer) noexcept -> packet &;
|
||||
@ -226,6 +226,8 @@ public:
|
||||
return buffer_.at(index);
|
||||
}
|
||||
};
|
||||
|
||||
using packet = packet;
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_COMM_PACKET_PACKET_HPP_
|
||||
#endif // INCLUDE_COMM_PACKET_PACKET_HPP_
|
||||
|
@ -19,11 +19,10 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
||||
#ifndef INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
||||
#define INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
||||
|
||||
#include "comm/packet/packet.hpp"
|
||||
#include "types/remote.hpp"
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
@ -37,7 +36,9 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
packet_client(remote::remote_config cfg);
|
||||
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();
|
||||
|
||||
@ -48,7 +49,12 @@ public:
|
||||
|
||||
private:
|
||||
boost::asio::io_context io_context_;
|
||||
remote::remote_config cfg_;
|
||||
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_;
|
||||
std::string unique_id_;
|
||||
|
||||
private:
|
||||
@ -69,22 +75,22 @@ private:
|
||||
|
||||
void put_client(std::shared_ptr<client> &cli);
|
||||
|
||||
[[nodiscard]] auto read_packet(client &cli, packet &response)
|
||||
-> packet::error_type;
|
||||
[[nodiscard]] auto read_packet(client &cli,
|
||||
packet &response) -> packet::error_type;
|
||||
|
||||
void resolve();
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto send(std::string_view method, std::uint32_t &service_flags)
|
||||
-> packet::error_type;
|
||||
[[nodiscard]] auto send(std::string_view method,
|
||||
std::uint32_t &service_flags) -> packet::error_type;
|
||||
|
||||
[[nodiscard]] auto send(std::string_view method, packet &request,
|
||||
std::uint32_t &service_flags) -> packet::error_type;
|
||||
|
||||
[[nodiscard]] auto send(std::string_view method, packet &request,
|
||||
packet &response, std::uint32_t &service_flags)
|
||||
-> packet::error_type;
|
||||
packet &response,
|
||||
std::uint32_t &service_flags) -> packet::error_type;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
||||
#endif // INCLUDE_COMM_PACKET_PACKET_CLIENT_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
|
||||
#define REPERTORY_INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
|
||||
#ifndef INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
|
||||
#define 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(io_context &ctx, tcp::acceptor &acceptor_)
|
||||
: socket(ctx), acceptor(acceptor_) {}
|
||||
connection(boost::asio::io_service &io_service, tcp::acceptor &acceptor_)
|
||||
: socket(io_service), 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_;
|
||||
io_context io_context_;
|
||||
boost::asio::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 // REPERTORY_INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
|
||||
#endif // INCLUDE_COMM_PACKET_PACKET_SERVER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_COMMON_HPP_
|
||||
#define REPERTORY_INCLUDE_COMMON_HPP_
|
||||
#ifndef INCLUDE_COMMON_HPP_
|
||||
#define INCLUDE_COMMON_HPP_
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// clang-format off
|
||||
@ -221,25 +221,44 @@ 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)
|
||||
@ -277,8 +296,8 @@ using namespace Fsp;
|
||||
#define INTERFACE_SETUP(name) \
|
||||
public: \
|
||||
name(const name &) noexcept = delete; \
|
||||
auto operator=(const name &) noexcept -> name & = delete; \
|
||||
auto operator=(name &&) noexcept -> name & = delete; \
|
||||
name &operator=(const name &) noexcept = delete; \
|
||||
name &operator=(name &&) noexcept = delete; \
|
||||
\
|
||||
protected: \
|
||||
name() = default; \
|
||||
@ -288,4 +307,4 @@ public: \
|
||||
virtual ~name() = default
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // REPERTORY_INCLUDE_COMMON_HPP_
|
||||
#endif // INCLUDE_COMMON_HPP_
|
||||
|
237
repertory/librepertory/include/database/db_common.hpp
Normal file
237
repertory/librepertory/include/database/db_common.hpp
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
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 db_comp_data_t final {
|
||||
std::string column_name;
|
||||
std::string op_type;
|
||||
};
|
||||
|
||||
struct db_context_t {
|
||||
db_context_t(sqlite3 &db3_, std::string table_name_)
|
||||
: db3(db3_), table_name(std::move(table_name_)) {}
|
||||
sqlite3 &db3;
|
||||
std::string table_name;
|
||||
|
||||
db3_stmt_t stmt{nullptr};
|
||||
};
|
||||
|
||||
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 (not has_row()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
row = db_row{context_};
|
||||
set_res(sqlite3_step(context_->stmt.get()), function_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
[[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_
|
@ -19,55 +19,46 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_
|
||||
#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
#ifndef INCLUDE_DATABASE_DB_DELETE_HPP_
|
||||
#define INCLUDE_DATABASE_DB_DELETE_HPP_
|
||||
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
#include "database/db_common.hpp"
|
||||
|
||||
#include "utils/db/sqlite/db_where_t.hpp"
|
||||
#include "database/db_where_t.hpp"
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
namespace repertory::db {
|
||||
class db_delete final {
|
||||
public:
|
||||
struct context final : db_context_t {
|
||||
struct db_delete_op_t final {
|
||||
std::shared_ptr<context> ctx;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
};
|
||||
|
||||
context(sqlite3 *db3_, std::string table_name_)
|
||||
context(sqlite3 &db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
using w_t = db_where_t<context, db_delete>;
|
||||
|
||||
using w_t = db_where_t<context, db_delete_op_t>;
|
||||
using wd_t = where_data_t<w_t>;
|
||||
|
||||
std::unique_ptr<wd_t> where_data;
|
||||
std::optional<w_t> where;
|
||||
std::vector<db_types_t> where_values;
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
||||
public:
|
||||
db_delete(sqlite3 &db3, std::string table_name)
|
||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||
: context_(std::make_shared<context>(db3, table_name)) {}
|
||||
|
||||
db_delete(std::shared_ptr<context> ctx) : ctx_(std::move(ctx)) {}
|
||||
db_delete(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<context> ctx_;
|
||||
std::shared_ptr<context> context_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
[[nodiscard]] auto go() const -> db_result<context>;
|
||||
|
||||
[[nodiscard]] auto
|
||||
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||
};
|
||||
} // namespace repertory::utils::db::sqlite
|
||||
} // namespace repertory::db
|
||||
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_
|
||||
#endif // INCLUDE_DATABASE_DB_DELETE_HPP_
|
@ -19,46 +19,46 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_
|
||||
#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
#ifndef INCLUDE_DATABASE_DB_INSERT_HPP_
|
||||
#define INCLUDE_DATABASE_DB_INSERT_HPP_
|
||||
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
#include "database/db_common.hpp"
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
namespace repertory::db {
|
||||
class db_insert final {
|
||||
public:
|
||||
struct context final : db_context_t {
|
||||
context(sqlite3 *db3_, std::string table_name_)
|
||||
context(sqlite3 &db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
|
||||
bool or_replace{false};
|
||||
std::map<std::string, db_types_t> values;
|
||||
std::map<std::string, db_types_t> values{};
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
||||
public:
|
||||
db_insert(sqlite3 &db3, std::string table_name)
|
||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||
: context_(std::make_shared<context>(db3, table_name)) {}
|
||||
|
||||
db_insert(std::shared_ptr<context> ctx) : ctx_(std::move(ctx)) {}
|
||||
db_insert(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<context> ctx_;
|
||||
std::shared_ptr<context> context_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto or_replace() -> db_insert {
|
||||
ctx_->or_replace = true;
|
||||
[[nodiscard]] auto or_replace() -> db_insert & {
|
||||
context_->or_replace = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto column_value(std::string column_name, db_types_t value)
|
||||
-> db_insert;
|
||||
[[nodiscard]] auto column_value(std::string column_name,
|
||||
db_types_t value) -> db_insert &;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
[[nodiscard]] auto go() const -> db_result<context>;
|
||||
};
|
||||
} // namespace repertory::utils::db::sqlite
|
||||
} // namespace repertory::db
|
||||
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_
|
||||
#endif // INCLUDE_DATABASE_DB_INSERT_HPP_
|
78
repertory/librepertory/include/database/db_select.hpp
Normal file
78
repertory/librepertory/include/database/db_select.hpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
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 : db_context_t {
|
||||
context(sqlite3 &db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
using w_t = db_where_with_limit_t<context, db_select>;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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_
|
@ -19,73 +19,57 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_UPDATE_HPP_
|
||||
#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_UPDATE_HPP_
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
#ifndef INCLUDE_DATABASE_DB_UPDATE_HPP_
|
||||
#define INCLUDE_DATABASE_DB_UPDATE_HPP_
|
||||
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
#include "database/db_common.hpp"
|
||||
|
||||
#include "utils/db/sqlite/db_where_t.hpp"
|
||||
#include "database/db_where_limit_t.hpp"
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
namespace repertory::db {
|
||||
class db_update final {
|
||||
public:
|
||||
struct context final : db_context_t {
|
||||
context(sqlite3 *db3_, std::string table_name_)
|
||||
context(sqlite3 &db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
using w_t = db_where_with_limit_t<context, db_update>;
|
||||
|
||||
struct db_update_op_t final {
|
||||
std::shared_ptr<context> ctx;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
|
||||
[[nodiscard]] auto limit(std::int32_t value) -> db_update_op_t;
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
|
||||
-> db_update_op_t;
|
||||
};
|
||||
|
||||
using w_t = db_where_t<context, db_update_op_t>;
|
||||
using wd_t = where_data_t<w_t>;
|
||||
|
||||
std::map<std::string, db_types_t> column_values;
|
||||
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::unique_ptr<wd_t> where_data;
|
||||
std::optional<w_t> where;
|
||||
std::vector<db_types_t> where_values;
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
||||
public:
|
||||
db_update(sqlite3 &db3, std::string table_name)
|
||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||
: context_(std::make_shared<context>(db3, table_name)) {}
|
||||
|
||||
db_update(std::shared_ptr<context> ctx) : ctx_(std::move(ctx)) {}
|
||||
db_update(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<context> ctx_;
|
||||
std::shared_ptr<context> context_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto column_value(std::string column_name, db_types_t value)
|
||||
-> db_update;
|
||||
[[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;
|
||||
[[nodiscard]] auto go() const -> db_result<context>;
|
||||
|
||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
||||
-> context::w_t::wn_t;
|
||||
[[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 limit(std::int32_t value) -> db_update &;
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
-> 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::utils::db::sqlite
|
||||
} // namespace repertory::db
|
||||
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_UPDATE_HPP_
|
||||
#endif // INCLUDE_DATABASE_DB_UPDATE_HPP_
|
214
repertory/librepertory/include/database/db_where_limit_t.hpp
Normal file
214
repertory/librepertory/include/database/db_where_limit_t.hpp
Normal file
@ -0,0 +1,214 @@
|
||||
/*
|
||||
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(db_comp_data_t{
|
||||
column_name,
|
||||
operation,
|
||||
});
|
||||
|
||||
ctx->where_values.push_back(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<db_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 db_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_
|
@ -19,134 +19,111 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_T_HPP_
|
||||
#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_T_HPP_
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
#ifndef INCLUDE_DATABASE_DB_WHERE_T_HPP_
|
||||
#define INCLUDE_DATABASE_DB_WHERE_T_HPP_
|
||||
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
template <typename w_t> struct where_data_t final {
|
||||
w_t base;
|
||||
std::map<std::size_t, std::vector<typename w_t::action_t>> actions;
|
||||
std::vector<db_types_t> values;
|
||||
};
|
||||
#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_t final {
|
||||
std::size_t action_idx{};
|
||||
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 w_t{action_idx, ctx}.where(column_name);
|
||||
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_data->base.dump(idx);
|
||||
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 w_t{action_idx, ctx}.group(std::move(func));
|
||||
}
|
||||
|
||||
[[nodiscard]] auto op() -> op_t {
|
||||
return op_t{
|
||||
ctx,
|
||||
};
|
||||
return next.group(std::move(func));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename cn_t, typename ctx_t, typename op_t, typename w_t>
|
||||
struct db_where_next_t final {
|
||||
std::size_t action_idx{};
|
||||
std::shared_ptr<ctx_t> ctx;
|
||||
w_t *owner;
|
||||
|
||||
using n_t = db_next_t<cn_t, ctx_t, op_t, w_t, db_where_next_t>;
|
||||
|
||||
[[nodiscard]] auto and_() -> n_t {
|
||||
n_t next{
|
||||
action_idx,
|
||||
[[nodiscard]] auto and_() -> n_t & {
|
||||
owner->actions.emplace_back(n_t{
|
||||
ctx,
|
||||
"AND",
|
||||
};
|
||||
});
|
||||
|
||||
ctx->where_data->actions[action_idx].emplace_back(next);
|
||||
return next;
|
||||
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_data->base.dump(idx);
|
||||
return ctx->where->dump(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
|
||||
|
||||
[[nodiscard]] auto op() -> op_t {
|
||||
return op_t{
|
||||
ctx,
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] auto or_() -> n_t {
|
||||
n_t next{
|
||||
action_idx,
|
||||
[[nodiscard]] auto or_() -> n_t & {
|
||||
owner->actions.emplace_back(n_t{
|
||||
ctx,
|
||||
"OR",
|
||||
};
|
||||
});
|
||||
|
||||
ctx->where_data->actions[action_idx].emplace_back(next);
|
||||
return next;
|
||||
return std::get<n_t>(*std::prev(owner->actions.end()));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ctx_t, typename op_t, typename w_t>
|
||||
struct db_comp_next_t final {
|
||||
std::size_t action_idx{};
|
||||
std::shared_ptr<ctx_t> ctx;
|
||||
w_t *owner;
|
||||
std::string column_name;
|
||||
|
||||
using wn_t = db_where_next_t<db_comp_next_t, ctx_t, op_t, w_t>;
|
||||
|
||||
[[nodiscard]] auto create(std::string operation, db_types_t value) {
|
||||
ctx->where_data->actions[action_idx].emplace_back(db_comp_data_t{
|
||||
[[nodiscard]] auto create(std::string operation, db::db_types_t value) {
|
||||
owner->actions.emplace_back(db_comp_data_t{
|
||||
column_name,
|
||||
operation,
|
||||
});
|
||||
|
||||
ctx->where_data->values.push_back(value);
|
||||
ctx->where_values.push_back(value);
|
||||
|
||||
return wn_t{
|
||||
action_idx,
|
||||
ctx,
|
||||
owner,
|
||||
};
|
||||
}
|
||||
|
||||
auto equals(db_types_t value) -> wn_t { return create("=", value); };
|
||||
auto equals(db::db_types_t value) -> wn_t { return create("=", value); };
|
||||
|
||||
auto gt(db_types_t value) -> wn_t { return create(">", value); }
|
||||
auto gt(db::db_types_t value) -> wn_t { return create(">", value); }
|
||||
|
||||
auto gte(db_types_t value) -> wn_t { return create(">=", value); }
|
||||
auto gte(db::db_types_t value) -> wn_t { return create(">=", value); }
|
||||
|
||||
auto like(db_types_t value) -> wn_t { return create("LIKE", value); }
|
||||
auto like(db::db_types_t value) -> wn_t { return create("LIKE", value); }
|
||||
|
||||
auto lt(db_types_t value) -> wn_t { return create("<", value); }
|
||||
auto lt(db::db_types_t value) -> wn_t { return create("<", value); }
|
||||
|
||||
auto lte(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_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_t final {
|
||||
std::size_t action_idx{0U};
|
||||
std::shared_ptr<ctx_t> ctx;
|
||||
|
||||
using cn_t = db_comp_next_t<ctx_t, op_t, db_where_t>;
|
||||
@ -157,21 +134,24 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
|
||||
|
||||
using action_t = std::variant<db_comp_data_t, n_t, db_where_t>;
|
||||
|
||||
std::vector<action_t> actions{};
|
||||
|
||||
[[nodiscard]] static auto dump(std::int32_t &idx,
|
||||
auto &&actions) -> std::string {
|
||||
auto &&data) -> std::string {
|
||||
std::stringstream stream;
|
||||
|
||||
for (auto &&action : actions) {
|
||||
for (auto &&action : data.actions) {
|
||||
std::visit(overloaded{
|
||||
[&idx, &stream](const db_comp_data_t &comp) {
|
||||
stream << '"' << comp.column_name << '"' << comp.op_type
|
||||
<< '?' + std::to_string(++idx);
|
||||
},
|
||||
[&idx, &stream](const n_t &next) {
|
||||
stream << ' ' << next.action << ' ';
|
||||
stream << ' ' << next.action << ' '
|
||||
<< dump(idx, next.next);
|
||||
},
|
||||
[&idx, &stream](const db_where_t &where) {
|
||||
stream << '(' << dump(idx, where.get_actions()) << ')';
|
||||
stream << '(' << dump(idx, where) << ')';
|
||||
},
|
||||
},
|
||||
action);
|
||||
@ -183,42 +163,28 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
|
||||
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
||||
|
||||
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
|
||||
return dump(idx, ctx->where_data->actions[action_idx]);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_actions() -> auto & {
|
||||
return ctx->where_data->actions[action_idx];
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_actions() const -> const auto & {
|
||||
return ctx->where_data->actions[action_idx];
|
||||
return dump(idx, *this);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto group(group_func_t func) -> wn_t {
|
||||
ctx->where_data->actions[action_idx];
|
||||
|
||||
db_where_t where{ctx->where_data->actions.size(), ctx};
|
||||
db_where_t where{ctx};
|
||||
func(where);
|
||||
|
||||
ctx->where_data->actions[action_idx].emplace_back(where);
|
||||
|
||||
actions.emplace_back(std::move(where));
|
||||
return wn_t{
|
||||
action_idx,
|
||||
ctx,
|
||||
this,
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) -> cn_t {
|
||||
ctx->where_data->actions[action_idx];
|
||||
|
||||
return cn_t{
|
||||
action_idx,
|
||||
ctx,
|
||||
this,
|
||||
column_name,
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace repertory::utils::db::sqlite
|
||||
} // namespace repertory::db
|
||||
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_T_HPP_
|
||||
#endif // INCLUDE_DATABASE_DB_WHERE_T_HPP_
|
@ -1,34 +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 REPERTORY_INCLUDE_DB_FILE_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_FILE_DB_HPP_
|
||||
|
||||
#include "db/i_file_db.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class app_config;
|
||||
|
||||
[[nodiscard]] auto create_file_db(const app_config &cfg)
|
||||
-> std::unique_ptr<i_file_db>;
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DB_FILE_DB_HPP_
|
@ -1,34 +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 REPERTORY_INCLUDE_DB_FILE_MGR_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_FILE_MGR_DB_HPP_
|
||||
|
||||
#include "db/i_file_mgr_db.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class app_config;
|
||||
|
||||
[[nodiscard]] auto
|
||||
create_file_mgr_db(const app_config &cfg) -> std::unique_ptr<i_file_mgr_db>;
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DB_FILE_MGR_DB_HPP_
|
@ -1,95 +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 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;
|
||||
|
||||
[[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() 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_
|
@ -1,86 +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 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;
|
||||
};
|
||||
|
||||
struct upload_entry final {
|
||||
std::string api_path;
|
||||
std::string source_path;
|
||||
};
|
||||
|
||||
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_
|
@ -1,78 +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 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;
|
||||
|
||||
[[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_
|
@ -1,117 +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 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;
|
||||
|
||||
[[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() 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_
|
@ -1,109 +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 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_
|
@ -1,127 +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 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;
|
||||
|
||||
[[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_
|
@ -1,92 +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 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;
|
||||
|
||||
[[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() 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_
|
@ -1,82 +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 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_
|
@ -1,34 +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 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_
|
@ -19,10 +19,11 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
|
||||
#define INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
|
||||
|
||||
#include "utils/single_thread_service_base.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace repertory {
|
||||
class directory_iterator;
|
||||
@ -34,7 +35,7 @@ public:
|
||||
private:
|
||||
struct open_directory final {
|
||||
std::shared_ptr<directory_iterator> iterator;
|
||||
std::vector<std::uint64_t> handles;
|
||||
std::vector<std::uint64_t> handles{};
|
||||
std::chrono::system_clock::time_point last_update{
|
||||
std::chrono::system_clock::now()};
|
||||
};
|
||||
@ -60,8 +61,8 @@ 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)
|
||||
-> std::shared_ptr<directory_iterator>;
|
||||
@ -73,4 +74,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
|
||||
#endif // INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
|
||||
#ifndef INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
|
||||
#define INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
|
||||
|
||||
#include "types/remote.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -78,4 +78,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
|
||||
#endif // INCLUDE_DRIVES_DIRECTORY_ITERATOR_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_EVICTION_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_EVICTION_HPP_
|
||||
#ifndef INCLUDE_DRIVES_EVICTION_HPP_
|
||||
#define INCLUDE_DRIVES_EVICTION_HPP_
|
||||
|
||||
#include "utils/single_thread_service_base.hpp"
|
||||
|
||||
@ -31,19 +31,18 @@ class i_provider;
|
||||
|
||||
class eviction final : public single_thread_service_base {
|
||||
public:
|
||||
eviction(i_provider &provider, const app_config &config,
|
||||
i_file_manager &file_mgr)
|
||||
eviction(i_provider &provider, const app_config &config, i_file_manager &fm)
|
||||
: single_thread_service_base("eviction"),
|
||||
provider_(provider),
|
||||
config_(config),
|
||||
file_mgr_(file_mgr),
|
||||
provider_(provider) {}
|
||||
fm_(fm) {}
|
||||
|
||||
~eviction() override = default;
|
||||
|
||||
private:
|
||||
const app_config &config_;
|
||||
i_file_manager &file_mgr_;
|
||||
i_provider &provider_;
|
||||
const app_config &config_;
|
||||
i_file_manager &fm_;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto check_minimum_requirements(const std::string &file_path)
|
||||
@ -56,4 +55,4 @@ protected:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_EVICTION_HPP_
|
||||
#endif // INCLUDE_DRIVES_EVICTION_HPP_
|
||||
|
@ -19,23 +19,23 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
||||
#define INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
||||
|
||||
#include "events/event_system.hpp"
|
||||
|
||||
namespace repertory {
|
||||
// clang-format off
|
||||
E_SIMPLE3(fuse_event, debug, true,
|
||||
std::string, function, func, E_FROM_STRING,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, function, func, E_STRING,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
int, result, res, E_FROM_INT32
|
||||
);
|
||||
|
||||
E_SIMPLE1(fuse_args_parsed, info, true,
|
||||
std::string, arguments, args, E_FROM_STRING
|
||||
std::string, arguments, args, E_STRING
|
||||
);
|
||||
// clang-format on
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
||||
#define INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "events/event_system.hpp"
|
||||
@ -604,4 +604,4 @@ public:
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
|
||||
#define INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "drives/fuse/fuse_drive_base.hpp"
|
||||
@ -103,7 +103,7 @@ protected:
|
||||
struct fuse_file_info *file_info) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
fgetattr_impl(std::string api_path, struct stat *unix_st,
|
||||
fgetattr_impl(std::string api_path, struct stat *st,
|
||||
struct fuse_file_info *file_info) -> api_error override;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
@ -124,11 +124,11 @@ protected:
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
[[nodiscard]] auto
|
||||
getattr_impl(std::string api_path, struct stat *unix_st,
|
||||
getattr_impl(std::string api_path, struct stat *st,
|
||||
struct fuse_file_info *file_info) -> api_error override;
|
||||
#else
|
||||
[[nodiscard]] auto getattr_impl(std::string api_path,
|
||||
struct stat *unix_st) -> api_error override;
|
||||
struct stat *st) -> api_error override;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
@ -323,4 +323,4 @@ public:
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
|
||||
#define 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 // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
|
||||
#define INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
@ -81,4 +81,4 @@ public:
|
||||
} // namespace repertory
|
||||
|
||||
#endif
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
|
||||
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
|
||||
|
||||
#include "drives/remote/i_remote_json.hpp"
|
||||
#include "types/remote.hpp"
|
||||
@ -30,25 +30,26 @@ 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,
|
||||
@ -60,21 +61,24 @@ 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;
|
||||
@ -83,9 +87,10 @@ 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;
|
||||
|
||||
@ -93,63 +98,65 @@ 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,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type = 0;
|
||||
[[nodiscard]] virtual auto fuse_read(const char *path, char *buffer,
|
||||
const remote::file_size &read_size,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
fuse_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
|
||||
@ -158,35 +165,36 @@ 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,
|
||||
const remote::file_size &writeSize,
|
||||
const remote::file_offset &writeOffset,
|
||||
const remote::file_handle &handle) -> packet::error_type = 0;
|
||||
[[nodiscard]] virtual auto fuse_write(const char *path, const char *buffer,
|
||||
const remote::file_size &writeSize,
|
||||
const remote::file_offset &writeOffset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type = 0;
|
||||
|
||||
[[nodiscard]] virtual auto fuse_write_base64(
|
||||
const char *path, const char *buffer, const remote::file_size &writeSize,
|
||||
const remote::file_offset &writeOffset,
|
||||
const remote::file_handle &handle) -> packet::error_type = 0;
|
||||
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;
|
||||
@ -196,4 +204,4 @@ using remote_instance_factory =
|
||||
std::function<std::unique_ptr<i_remote_instance>()>;
|
||||
} // namespace repertory::remote_fuse
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_I_REMOTE_INSTANCE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
|
||||
#define 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,21 +67,23 @@ 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 ;
|
||||
@ -90,9 +92,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;
|
||||
|
||||
@ -107,25 +110,27 @@ 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;
|
||||
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_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;
|
||||
[[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;
|
||||
|
||||
[[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)
|
||||
@ -139,8 +144,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;
|
||||
@ -157,8 +162,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
|
||||
@ -169,45 +174,48 @@ 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,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type override;
|
||||
[[nodiscard]] auto fuse_write(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type override;
|
||||
|
||||
[[nodiscard]] auto fuse_write_base64(
|
||||
const char *path, const char *buffer, const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type override;
|
||||
[[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> 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;
|
||||
@ -215,4 +223,4 @@ public:
|
||||
} // namespace remote_fuse
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_CLIENT_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
|
||||
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "drives/fuse/fuse_base.hpp"
|
||||
@ -238,4 +238,4 @@ protected:
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
|
||||
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
|
||||
#define 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,28 +88,25 @@ 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 ;
|
||||
@ -118,10 +115,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;
|
||||
|
||||
@ -129,30 +125,28 @@ 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,
|
||||
const remote::file_offset &read_offset,
|
||||
const 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;
|
||||
|
||||
[[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)
|
||||
@ -166,8 +160,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;
|
||||
@ -184,8 +178,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
|
||||
@ -195,70 +189,67 @@ 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,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type override;
|
||||
[[nodiscard]] auto
|
||||
fuse_write(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type override;
|
||||
|
||||
[[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type override;
|
||||
[[nodiscard]] auto fuse_write_base64(
|
||||
const char *path, const char *buffer, const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> 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_deleted)
|
||||
-> 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_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,
|
||||
@ -273,66 +264,60 @@ public:
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type override;
|
||||
|
||||
[[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;
|
||||
|
||||
[[nodiscard]] auto winfsp_get_volume_info(
|
||||
UINT64 &total_size, UINT64 &free_size,
|
||||
std::string &volume_label) -> packet::error_type override;
|
||||
|
||||
[[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;
|
||||
winfsp_mounted(const std::wstring &location) -> 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_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_mounted(const std::wstring &location)
|
||||
-> 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_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_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
|
||||
PUINT32 bytes_transferred) -> 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_directory(PVOID file_desc, PWSTR /*pattern*/, PWSTR marker,
|
||||
json &itemList) -> 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_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 // REPERTORY_INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
|
||||
#endif // INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
|
||||
#ifndef INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
|
||||
#define INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
|
||||
|
||||
#include "comm/packet/packet.hpp"
|
||||
|
||||
@ -30,17 +30,18 @@ class i_remote_json {
|
||||
|
||||
public:
|
||||
[[nodiscard]] virtual auto
|
||||
json_create_directory_snapshot(const std::string &path,
|
||||
json &json_data) -> packet::error_type = 0;
|
||||
json_create_directory_snapshot(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 // REPERTORY_INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
|
||||
#endif // INCLUDE_DRIVES_REMOTE_I_REMOTE_JSON_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
|
||||
#define INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
|
||||
|
||||
#include "types/remote.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -33,32 +33,25 @@ protected:
|
||||
virtual ~remote_open_file_table() = default;
|
||||
|
||||
protected:
|
||||
struct compat_open_info final {
|
||||
std::string client_id;
|
||||
std::vector<remote::file_handle> handles;
|
||||
struct compat_open_info {
|
||||
std::size_t count = 0u;
|
||||
std::string client_id = "";
|
||||
std::string path;
|
||||
};
|
||||
|
||||
struct open_info final {
|
||||
std::string client_id;
|
||||
PVOID directory_buffer{nullptr};
|
||||
std::vector<native_handle> handles;
|
||||
struct open_info {
|
||||
std::size_t count = 0u;
|
||||
std::string client_id = "";
|
||||
PVOID directory_buffer = nullptr;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
private:
|
||||
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<remote::file_handle, compat_open_info> compat_lookup_;
|
||||
std::recursive_mutex compat_mutex_;
|
||||
std::unordered_map<std::string, std::vector<std::uint64_t>> directory_lookup_;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<open_info>> file_lookup_;
|
||||
std::unordered_map<native_handle, std::string> handle_lookup_;
|
||||
|
||||
private:
|
||||
std::recursive_mutex directory_mutex_;
|
||||
std::unordered_map<native_handle, open_info> file_lookup_;
|
||||
mutable std::recursive_mutex file_mutex_;
|
||||
|
||||
protected:
|
||||
@ -71,11 +64,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;
|
||||
@ -84,21 +77,20 @@ 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 handle_lookup_.contains(handle) ? 0 : error_return;
|
||||
return ((file_lookup_.find(handle) == file_lookup_.end()) ? error_return
|
||||
: 0);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -110,12 +102,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 op_info);
|
||||
void set_open_info(const native_handle &handle, open_info oi);
|
||||
|
||||
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 // REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
|
||||
#endif // INCLUDE_DRIVES_REMOTE_REMOTE_OPEN_FILE_TABLE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
|
||||
#define INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "comm/packet/client_pool.hpp"
|
||||
@ -29,8 +29,6 @@
|
||||
#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/events.hpp"
|
||||
#include "types/remote.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/base64.hpp"
|
||||
@ -54,7 +52,7 @@ public:
|
||||
: config_(config),
|
||||
drive_(drv),
|
||||
mount_location_(std::move(mount_location)),
|
||||
client_pool_(config.get_remote_mount().client_pool_size) {
|
||||
client_pool_(config.get_remote_client_pool_size()) {
|
||||
event_system::instance().raise<service_started>("remote_server_base");
|
||||
handler_lookup_.insert(
|
||||
{"::winfsp_can_delete",
|
||||
@ -87,10 +85,10 @@ public:
|
||||
UINT32 flags{};
|
||||
DECODE_OR_RETURN(request, flags);
|
||||
|
||||
BOOLEAN was_deleted{};
|
||||
BOOLEAN was_closed{};
|
||||
ret = this->winfsp_cleanup(file_desc, file_name.data(), flags,
|
||||
was_deleted);
|
||||
response.encode(was_deleted);
|
||||
was_closed);
|
||||
response.encode(was_closed);
|
||||
|
||||
return ret;
|
||||
}});
|
||||
@ -139,12 +137,12 @@ public:
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
#if defined(_WIN32)
|
||||
this->set_client_id(file_desc, client_id);
|
||||
#else // !defined(_WIN32)
|
||||
#else
|
||||
this->set_client_id(
|
||||
static_cast<native_handle>(
|
||||
reinterpret_cast<std::uintptr_t>(file_desc)),
|
||||
client_id);
|
||||
#endif // defined(_WIN32)
|
||||
#endif
|
||||
response.encode(file_desc);
|
||||
response.encode(file_info);
|
||||
response.encode(normalized_name);
|
||||
@ -279,12 +277,12 @@ public:
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
#if defined(_WIN32)
|
||||
this->set_client_id(file_desc, client_id);
|
||||
#else // !defined(_WIN32)
|
||||
#else
|
||||
this->set_client_id(
|
||||
static_cast<native_handle>(
|
||||
reinterpret_cast<std::uintptr_t>(file_desc)),
|
||||
client_id);
|
||||
#endif // defined(_WIN32)
|
||||
#endif
|
||||
response.encode(file_desc);
|
||||
response.encode(file_info);
|
||||
response.encode(normalized_name);
|
||||
@ -587,9 +585,9 @@ public:
|
||||
0) {
|
||||
#if defined(_WIN32)
|
||||
this->set_compat_client_id(handle, client_id);
|
||||
#else // !defined(_WIN32)
|
||||
#else
|
||||
this->set_client_id(static_cast<native_handle>(handle), client_id);
|
||||
#endif // defined(_WIN32)
|
||||
#endif
|
||||
response.encode(handle);
|
||||
}
|
||||
return ret;
|
||||
@ -843,9 +841,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 // !defined(_WIN32)
|
||||
#else
|
||||
this->set_client_id(static_cast<native_handle>(handle), client_id);
|
||||
#endif // defined(_WIN32)
|
||||
#endif
|
||||
response.encode(handle);
|
||||
}
|
||||
return ret;
|
||||
@ -1359,8 +1357,7 @@ public:
|
||||
}});
|
||||
|
||||
packet_server_ = std::make_unique<packet_server>(
|
||||
config_.get_remote_mount().api_port,
|
||||
config_.get_remote_mount().encryption_token, 10,
|
||||
config_.get_remote_port(), config_.get_remote_token(), 10,
|
||||
[this](const std::string &client_id) {
|
||||
return this->closed_handler(client_id);
|
||||
},
|
||||
@ -1433,4 +1430,4 @@ protected:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
|
||||
#endif // INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
|
||||
#define INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "types/remote.hpp"
|
||||
@ -31,25 +31,22 @@ 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_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_items(const std::string &api_path) const
|
||||
-> directory_item_list = 0;
|
||||
get_file_size(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;
|
||||
[[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,
|
||||
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_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,
|
||||
@ -65,11 +62,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) const
|
||||
-> api_error = 0;
|
||||
[[nodiscard]] virtual auto
|
||||
populate_file_info(const std::string &api_path,
|
||||
remote::file_info &fi) -> api_error = 0;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
|
||||
#endif // INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
|
||||
#define 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_deleted) -> packet::error_type = 0;
|
||||
BOOLEAN &was_closed) -> packet::error_type = 0;
|
||||
|
||||
virtual auto winfsp_close(PVOID file_desc) -> packet::error_type = 0;
|
||||
|
||||
@ -50,8 +50,7 @@ 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
|
||||
@ -87,13 +86,11 @@ 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;
|
||||
@ -117,4 +114,4 @@ using remote_instance_factory =
|
||||
std::function<std::unique_ptr<i_remote_instance>()>;
|
||||
} // namespace repertory::remote_winfsp
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
|
||||
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_I_REMOTE_INSTANCE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
||||
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
||||
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
||||
|
||||
#include "comm/packet/packet.hpp"
|
||||
#include "comm/packet/packet_client.hpp"
|
||||
@ -50,20 +50,19 @@ 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_deleted) -> packet::error_type override;
|
||||
BOOLEAN &was_closed) -> packet::error_type override;
|
||||
|
||||
auto winfsp_close(PVOID file_desc) -> packet::error_type override;
|
||||
|
||||
@ -76,33 +75,32 @@ 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,
|
||||
BOOLEAN replace_attributes, UINT64 allocation_size,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type override;
|
||||
auto
|
||||
winfsp_overwrite(PVOID file_desc, UINT32 attributes,
|
||||
BOOLEAN replace_attributes, UINT64 allocation_size,
|
||||
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;
|
||||
@ -113,26 +111,25 @@ 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,
|
||||
BOOLEAN write_to_end, BOOLEAN constrained_io,
|
||||
PUINT32 bytes_transferred, remote::file_info *file_info)
|
||||
-> packet::error_type override;
|
||||
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;
|
||||
};
|
||||
} // namespace remote_winfsp
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
||||
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
||||
|
@ -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 REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
|
||||
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
|
||||
#define 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,43 +110,41 @@ 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,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type override;
|
||||
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;
|
||||
|
||||
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,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type override;
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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;
|
||||
@ -159,8 +157,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;
|
||||
@ -193,8 +191,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 {}
|
||||
@ -203,21 +201,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;
|
||||
|
||||
// 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_deleted) -> packet::error_type override;
|
||||
BOOLEAN &was_closed) -> packet::error_type override;
|
||||
|
||||
auto winfsp_close(PVOID file_desc) -> packet::error_type override;
|
||||
|
||||
@ -230,33 +227,32 @@ 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,
|
||||
BOOLEAN replace_attributes, UINT64 allocation_size,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type override;
|
||||
auto
|
||||
winfsp_overwrite(PVOID file_desc, UINT32 attributes,
|
||||
BOOLEAN replace_attributes, UINT64 allocation_size,
|
||||
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;
|
||||
@ -267,27 +263,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,
|
||||
BOOLEAN write_to_end, BOOLEAN constrained_io,
|
||||
PUINT32 bytes_transferred, remote::file_info *file_info)
|
||||
-> packet::error_type override;
|
||||
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;
|
||||
};
|
||||
} // namespace remote_winfsp
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
|
||||
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
|
||||
#define 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 // REPERTORY_INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
|
||||
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
|
||||
#define REPERTORY_INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
|
||||
#ifndef INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
|
||||
#define INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "drives/eviction.hpp"
|
||||
@ -53,11 +53,11 @@ private:
|
||||
~winfsp_service() override = default;
|
||||
|
||||
private:
|
||||
app_config &config_;
|
||||
winfsp_drive &drive_;
|
||||
std::vector<std::string> drive_args_;
|
||||
FileSystemHost host_;
|
||||
lock_data &lock_;
|
||||
winfsp_drive &drive_;
|
||||
const std::vector<std::string> drive_args_;
|
||||
FileSystemHost host_;
|
||||
app_config &config_;
|
||||
|
||||
protected:
|
||||
auto OnStart(ULONG, PWSTR *) -> NTSTATUS override;
|
||||
@ -75,28 +75,22 @@ private:
|
||||
std::unique_ptr<remote_winfsp::remote_server> remote_server_;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto handle_error(std::string_view function_name,
|
||||
const std::string &api_path, api_error error,
|
||||
FileInfo *file_info, std::uint64_t file_size,
|
||||
bool raise_on_failure_only = false) const
|
||||
-> NTSTATUS;
|
||||
|
||||
static auto parse_mount_location(const std::wstring &mount_location)
|
||||
-> std::string;
|
||||
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) const;
|
||||
FSP_FSCTL_OPEN_FILE_INFO &ofi);
|
||||
|
||||
void populate_file_info(std::uint64_t file_size, api_meta_map meta,
|
||||
FSP_FSCTL_FILE_INFO &fi) const;
|
||||
FSP_FSCTL_FILE_INFO &fi);
|
||||
|
||||
static void set_file_info(remote::file_info &dest,
|
||||
const FSP_FSCTL_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;
|
||||
@ -108,8 +102,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;
|
||||
@ -117,25 +111,24 @@ 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,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size)
|
||||
-> NTSTATUS override;
|
||||
[[nodiscard]] auto
|
||||
get_security_by_name(PWSTR file_name, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size) -> NTSTATUS override;
|
||||
|
||||
auto GetSecurityByName(PWSTR file_name, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
@ -159,16 +152,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) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
populate_file_info(const std::string &api_path,
|
||||
remote::file_info &file_info) -> api_error override;
|
||||
|
||||
auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
ULONG length, PULONG bytes_transferred) -> NTSTATUS override;
|
||||
@ -178,8 +171,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,
|
||||
@ -187,15 +180,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();
|
||||
|
||||
@ -207,4 +200,4 @@ public:
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
|
||||
#endif // INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||
#ifndef INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||
#define INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||
|
||||
#include "events/event_system.hpp"
|
||||
|
||||
@ -40,4 +40,4 @@ private:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||
#endif // INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||
#ifndef INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||
#define INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||
|
||||
#include "events/event_system.hpp"
|
||||
|
||||
@ -43,4 +43,4 @@ private:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||
#endif // INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_EVENT_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_EVENT_HPP_
|
||||
#ifndef INCLUDE_EVENTS_EVENT_HPP_
|
||||
#define INCLUDE_EVENTS_EVENT_HPP_
|
||||
|
||||
namespace repertory {
|
||||
enum class event_level {
|
||||
@ -32,12 +32,9 @@ enum class event_level {
|
||||
trace,
|
||||
};
|
||||
|
||||
[[nodiscard]] auto
|
||||
event_level_from_string(std::string level,
|
||||
event_level default_level = event_level::info)
|
||||
-> event_level;
|
||||
auto event_level_from_string(std::string level) -> event_level;
|
||||
|
||||
[[nodiscard]] auto event_level_to_string(event_level level) -> std::string;
|
||||
auto event_level_to_string(event_level level) -> std::string;
|
||||
|
||||
class event {
|
||||
protected:
|
||||
@ -75,18 +72,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<std::atomic<repertory::event_level>> {
|
||||
static void to_json(json &data,
|
||||
const std::atomic<repertory::event_level> &value) {
|
||||
data = repertory::event_level_to_string(value.load());
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
std::atomic<repertory::event_level> &value) {
|
||||
value.store(repertory::event_level_from_string(data.get<std::string>()));
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_EVENT_HPP_
|
||||
#endif // INCLUDE_EVENTS_EVENT_HPP_
|
||||
|
@ -19,32 +19,53 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
|
||||
#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"
|
||||
|
||||
namespace repertory {
|
||||
using event_system = t_event_system<event>;
|
||||
using event_consumer = event_system::event_consumer;
|
||||
|
||||
#define E_FROM_API_FILE_ERROR(e) api_error_to_string(e)
|
||||
#define E_FROM_BOOL(t) std::to_string(t)
|
||||
#define E_FROM_CURL_CODE(t) std::string(curl_easy_strerror(t))
|
||||
#define E_FROM_DOUBLE(d) std::to_string(d)
|
||||
#define E_FROM_DOUBLE_PRECISE(dbl_val) \
|
||||
#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_SIZE_T(t) std::to_string(t)
|
||||
#define E_FROM_STRING(t) 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)
|
||||
|
||||
#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_DOWNLOAD_TYPE(t) download_type_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)
|
||||
|
||||
#define E_PROP(type, name, short_name, ts) \
|
||||
private: \
|
||||
@ -238,4 +259,4 @@ private: \
|
||||
[this](const event &evt) { callback(evt); }))
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
|
||||
#endif // INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
|
||||
#ifndef INCLUDE_EVENTS_EVENTS_HPP_
|
||||
#define INCLUDE_EVENTS_EVENTS_HPP_
|
||||
|
||||
#include "events/event_system.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -29,267 +29,267 @@
|
||||
namespace repertory {
|
||||
// clang-format off
|
||||
E_SIMPLE2(curl_error, error, true,
|
||||
std::string, url, url, E_FROM_STRING,
|
||||
std::string, url, url, E_STRING,
|
||||
CURLcode, res, res, E_FROM_CURL_CODE
|
||||
);
|
||||
|
||||
E_SIMPLE3(debug_log, debug, true,
|
||||
std::string, function, func, E_FROM_STRING,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, data, data, E_FROM_STRING
|
||||
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_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE2(directory_removed_externally, warn, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, result, res, E_FROM_STRING
|
||||
std::string, location, loc, E_STRING,
|
||||
std::string, result, res, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(drive_mounted, info, true,
|
||||
std::string, location, loc, E_FROM_STRING
|
||||
std::string, location, loc, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(drive_mount_result, info, true,
|
||||
std::string, result, res, E_FROM_STRING
|
||||
std::string, result, res, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(drive_unmount_pending, info, true,
|
||||
std::string, location, loc, E_FROM_STRING
|
||||
std::string, location, loc, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(drive_unmounted, info, true,
|
||||
std::string, location, loc, E_FROM_STRING
|
||||
std::string, location, loc, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(event_level_changed, info, true,
|
||||
std::string, new_event_level, level, E_FROM_STRING
|
||||
std::string, new_event_level, level, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(failed_upload_queued, error, true,
|
||||
std::string, api_path, ap, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(failed_upload_removed, warn, true,
|
||||
std::string, api_path, ap, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(failed_upload_retry, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE2(file_get_failed, error, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
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_FROM_STRING
|
||||
std::string, error, err, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(file_pinned, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(file_read_bytes_failed, error, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING,
|
||||
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_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE2(file_removed_externally, warn, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, to_api_path, TO, E_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, parent, parent, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::uint64_t, handle, handle, E_FROM_UINT64,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::uint64_t, handle, handle, E_FROM_UINT64,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
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_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE4(file_upload_completed, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
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_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(file_upload_retry, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
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_FROM_STRING
|
||||
std::string, source, src, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(orphaned_file_detected, warn, true,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
std::string, source, src, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(orphaned_file_processing_failed, error, true,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
std::string, dest, dest, E_FROM_STRING,
|
||||
std::string, result, res, E_FROM_STRING
|
||||
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_FROM_STRING
|
||||
std::string, source, src, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(orphaned_source_file_removed, info, true,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
std::string, source, src, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(polling_item_begin, debug, true,
|
||||
std::string, item_name, item, E_FROM_STRING
|
||||
std::string, item_name, item, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(polling_item_end, debug, true,
|
||||
std::string, item_name, item, E_FROM_STRING
|
||||
std::string, item_name, item, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE2(provider_offline, error, true,
|
||||
std::string, host_name_or_ip, host, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
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_FROM_STRING,
|
||||
std::string, message, msg, E_FROM_STRING
|
||||
std::string, function, func, E_STRING,
|
||||
std::string, message, msg, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(rpc_server_exception, error, true,
|
||||
std::string, exception, exception, E_FROM_STRING
|
||||
std::string, exception, exception, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(service_shutdown_begin, debug, true,
|
||||
std::string, service, svc, E_FROM_STRING
|
||||
std::string, service, svc, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(service_shutdown_end, debug, true,
|
||||
std::string, service, svc, E_FROM_STRING
|
||||
std::string, service, svc, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(service_started, debug, true,
|
||||
std::string, service, svc, E_FROM_STRING
|
||||
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_FROM_STRING,
|
||||
std::string, result, res, E_FROM_STRING
|
||||
std::string, location, loc, E_STRING,
|
||||
std::string, result, res, E_STRING
|
||||
);
|
||||
#endif
|
||||
// clang-format on
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
|
||||
#endif // INCLUDE_EVENTS_EVENTS_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
||||
#ifndef INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
||||
#define INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
||||
|
||||
#include "events/event.hpp"
|
||||
#include "utils/collection.hpp"
|
||||
@ -190,4 +190,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
||||
#endif // INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
||||
|
@ -1,67 +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 REPERTORY_INCLUDE_FILE_MANAGER_CACHE_SIZE_MGR_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_CACHE_SIZE_MGR_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class app_config;
|
||||
|
||||
class cache_size_mgr final {
|
||||
public:
|
||||
cache_size_mgr(const cache_size_mgr &) = delete;
|
||||
cache_size_mgr(cache_size_mgr &&) = delete;
|
||||
auto operator=(const cache_size_mgr &) -> cache_size_mgr & = delete;
|
||||
auto operator=(cache_size_mgr &&) -> cache_size_mgr & = delete;
|
||||
|
||||
protected:
|
||||
cache_size_mgr() = default;
|
||||
|
||||
~cache_size_mgr() { stop(); }
|
||||
|
||||
private:
|
||||
static cache_size_mgr instance_;
|
||||
|
||||
private:
|
||||
app_config *cfg_{nullptr};
|
||||
std::uint64_t cache_size_{0U};
|
||||
mutable std::mutex mtx_;
|
||||
std::condition_variable notify_;
|
||||
stop_type stop_requested_{false};
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto expand(std::uint64_t size) -> api_error;
|
||||
|
||||
void initialize(app_config *cfg);
|
||||
|
||||
[[nodiscard]] static auto instance() -> cache_size_mgr & { return instance_; }
|
||||
|
||||
[[nodiscard]] auto shrink(std::uint64_t size) -> api_error;
|
||||
|
||||
[[nodiscard]] auto size() const -> std::uint64_t;
|
||||
|
||||
void stop();
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_CACHE_SIZE_MGR_HPP_
|
@ -1,83 +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 REPERTORY_INCLUDE_FILE_MANAGER_DIRECT_OPEN_FILE_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_DIRECT_OPEN_FILE_HPP_
|
||||
|
||||
#include "file_manager/ring_buffer_base.hpp"
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class i_provider;
|
||||
class i_upload_manager;
|
||||
|
||||
class direct_open_file final : public ring_buffer_base {
|
||||
public:
|
||||
direct_open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider);
|
||||
|
||||
~direct_open_file() override;
|
||||
|
||||
public:
|
||||
direct_open_file() = delete;
|
||||
direct_open_file(const direct_open_file &) noexcept = delete;
|
||||
direct_open_file(direct_open_file &&) noexcept = delete;
|
||||
auto operator=(direct_open_file &&) noexcept -> direct_open_file & = delete;
|
||||
auto
|
||||
operator=(const direct_open_file &) noexcept -> direct_open_file & = delete;
|
||||
|
||||
private:
|
||||
std::array<data_buffer, min_ring_size> ring_data_;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto on_check_start() -> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
on_chunk_downloaded(std::size_t /* chunk */,
|
||||
const data_buffer & /* buffer */) -> api_error override {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto
|
||||
on_read_chunk(std::size_t chunk, std::size_t read_size,
|
||||
std::uint64_t read_offset, data_buffer &data,
|
||||
std::size_t &bytes_read) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto use_buffer(std::size_t chunk,
|
||||
std::function<api_error(data_buffer &)> func)
|
||||
-> api_error override;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto native_operation(native_operation_callback /* callback */)
|
||||
-> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto native_operation(std::uint64_t /* new_file_size */,
|
||||
native_operation_callback /* callback */)
|
||||
-> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_DIRECT_OPEN_FILE_HPP_
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
||||
#ifndef INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
||||
#define INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
||||
|
||||
#include "events/events.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -28,59 +28,70 @@
|
||||
namespace repertory {
|
||||
// clang-format off
|
||||
E_SIMPLE2(download_begin, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE5(download_chunk_begin, debug, true,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING,
|
||||
std::size_t, chunk, chunk, E_FROM_SIZE_T,
|
||||
std::size_t, total, total, E_FROM_SIZE_T,
|
||||
std::size_t, complete, complete, E_FROM_SIZE_T
|
||||
);
|
||||
|
||||
E_SIMPLE6(download_chunk_end, debug, true,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING,
|
||||
std::size_t, chunk, chunk, E_FROM_SIZE_T,
|
||||
std::size_t, total, total, E_FROM_SIZE_T,
|
||||
std::size_t, complete, complete, E_FROM_SIZE_T,
|
||||
api_error, result, result, E_FROM_API_FILE_ERROR
|
||||
);
|
||||
|
||||
E_SIMPLE3(download_end, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING,
|
||||
api_error, result, result, E_FROM_API_FILE_ERROR
|
||||
);
|
||||
|
||||
E_SIMPLE3(download_progress, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING,
|
||||
double, progress, prog, E_FROM_DOUBLE_PRECISE
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING,
|
||||
double, progress, prog, E_DOUBLE_PRECISE
|
||||
);
|
||||
|
||||
E_SIMPLE2(download_restored, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(download_restore_failed, error, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING,
|
||||
std::string, error, err, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(download_resume_add_failed, error, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING,
|
||||
std::string, error, err, E_FROM_STRING
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING,
|
||||
std::string, error, err, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE2(download_resume_added, debug, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING
|
||||
E_SIMPLE2(download_resume_added, info, true,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE2(download_resume_removed, debug, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING
|
||||
E_SIMPLE2(download_resume_removed, info, true,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, dest_path, dest, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE1(item_timeout, trace, true,
|
||||
std::string, api_path, ap, E_FROM_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(download_type_selected, debug, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
download_type, download_type, type, E_FROM_DOWNLOAD_TYPE
|
||||
E_SIMPLE1(item_timeout, debug, true,
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
// clang-format on
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
||||
#endif // INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
||||
|
@ -19,16 +19,16 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
||||
#ifndef INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
||||
#define INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
||||
|
||||
#include "db/i_file_mgr_db.hpp"
|
||||
#include "database/db_common.hpp"
|
||||
#include "events/event_system.hpp"
|
||||
#include "events/events.hpp"
|
||||
#include "file_manager/i_file_manager.hpp"
|
||||
#include "file_manager/i_open_file.hpp"
|
||||
#include "file_manager/i_upload_manager.hpp"
|
||||
#include "file_manager/upload.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/file.hpp"
|
||||
|
||||
@ -39,6 +39,402 @@ class i_provider;
|
||||
class file_manager final : public i_file_manager, public i_upload_manager {
|
||||
E_CONSUMER();
|
||||
|
||||
public:
|
||||
class open_file_base : public i_closeable_open_file {
|
||||
public:
|
||||
open_file_base(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider);
|
||||
|
||||
open_file_base(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi,
|
||||
std::map<std::uint64_t, open_file_data> open_data,
|
||||
i_provider &provider);
|
||||
|
||||
~open_file_base() override = default;
|
||||
|
||||
public:
|
||||
open_file_base() = delete;
|
||||
open_file_base(const open_file_base &) noexcept = delete;
|
||||
open_file_base(open_file_base &&) noexcept = delete;
|
||||
auto operator=(open_file_base &&) noexcept -> open_file_base & = delete;
|
||||
auto
|
||||
operator=(const open_file_base &) noexcept -> open_file_base & = delete;
|
||||
|
||||
public:
|
||||
class download final {
|
||||
public:
|
||||
download() = default;
|
||||
|
||||
~download() = default;
|
||||
|
||||
public:
|
||||
download(const download &) noexcept = delete;
|
||||
download(download &&) noexcept = delete;
|
||||
auto operator=(download &&) noexcept -> download & = delete;
|
||||
auto operator=(const download &) noexcept -> download & = delete;
|
||||
|
||||
private:
|
||||
bool complete_{false};
|
||||
api_error error_{api_error::success};
|
||||
std::mutex mtx_;
|
||||
std::condition_variable notify_;
|
||||
|
||||
public:
|
||||
void notify(const api_error &err);
|
||||
|
||||
auto wait() -> api_error;
|
||||
};
|
||||
|
||||
class io_item final {
|
||||
public:
|
||||
io_item(std::function<api_error()> action) : action_(std::move(action)) {}
|
||||
|
||||
~io_item() = default;
|
||||
|
||||
public:
|
||||
io_item() = delete;
|
||||
io_item(const io_item &) noexcept = delete;
|
||||
io_item(io_item &&) noexcept = delete;
|
||||
auto operator=(io_item &&) noexcept -> io_item & = delete;
|
||||
auto operator=(const io_item &) noexcept -> io_item & = delete;
|
||||
|
||||
private:
|
||||
std::function<api_error()> action_;
|
||||
std::mutex mtx_;
|
||||
std::condition_variable notify_;
|
||||
std::optional<api_error> result_;
|
||||
|
||||
public:
|
||||
void action();
|
||||
|
||||
[[nodiscard]] auto get_result() -> api_error;
|
||||
};
|
||||
|
||||
protected:
|
||||
std::uint64_t chunk_size_;
|
||||
std::uint8_t chunk_timeout_;
|
||||
filesystem_item fsi_;
|
||||
std::size_t last_chunk_size_;
|
||||
std::map<std::uint64_t, open_file_data> open_data_;
|
||||
i_provider &provider_;
|
||||
|
||||
private:
|
||||
api_error error_{api_error::success};
|
||||
mutable std::mutex error_mtx_;
|
||||
stop_type io_stop_requested_{false};
|
||||
std::unique_ptr<std::thread> io_thread_;
|
||||
|
||||
protected:
|
||||
std::unordered_map<std::size_t, std::shared_ptr<download>>
|
||||
active_downloads_;
|
||||
mutable std::recursive_mutex file_mtx_;
|
||||
std::atomic<std::chrono::system_clock::time_point> last_access_{
|
||||
std::chrono::system_clock::now()};
|
||||
bool modified_{false};
|
||||
std::unique_ptr<utils::file::i_file> nf_;
|
||||
mutable std::mutex io_thread_mtx_;
|
||||
std::condition_variable io_thread_notify_;
|
||||
std::deque<std::shared_ptr<io_item>> io_thread_queue_;
|
||||
bool removed_{false};
|
||||
|
||||
private:
|
||||
void file_io_thread();
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto do_io(std::function<api_error()> action) -> api_error;
|
||||
|
||||
virtual auto is_download_complete() const -> bool = 0;
|
||||
|
||||
void reset_timeout();
|
||||
|
||||
auto set_api_error(const api_error &e) -> api_error;
|
||||
|
||||
public:
|
||||
void add(std::uint64_t handle, open_file_data ofd) override;
|
||||
|
||||
[[nodiscard]] auto can_close() const -> bool override;
|
||||
|
||||
auto close() -> bool override;
|
||||
|
||||
[[nodiscard]] auto get_api_error() const -> api_error;
|
||||
|
||||
[[nodiscard]] auto get_api_path() const -> std::string override;
|
||||
|
||||
[[nodiscard]] auto get_chunk_size() const -> std::size_t override {
|
||||
return chunk_size_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_file_size() const -> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item() const -> filesystem_item override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_handles() const -> std::vector<std::uint64_t> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_data() const -> std::map<std::uint64_t, open_file_data> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_data(std::uint64_t handle) const -> open_file_data override;
|
||||
|
||||
[[nodiscard]] auto get_open_file_count() const -> std::size_t override;
|
||||
|
||||
[[nodiscard]] auto get_source_path() const -> std::string override {
|
||||
return fsi_.source_path;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto has_handle(std::uint64_t handle) const -> bool override {
|
||||
return open_data_.find(handle) != open_data_.end();
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_directory() const -> bool override {
|
||||
return fsi_.directory;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_modified() const -> bool override;
|
||||
|
||||
void remove(std::uint64_t handle) override;
|
||||
|
||||
void set_api_path(const std::string &api_path) override;
|
||||
};
|
||||
|
||||
class open_file final : public open_file_base {
|
||||
public:
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider, i_upload_manager &mgr);
|
||||
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi,
|
||||
std::map<std::uint64_t, open_file_data> open_data,
|
||||
i_provider &provider, i_upload_manager &mgr);
|
||||
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider,
|
||||
std::optional<boost::dynamic_bitset<>> read_state,
|
||||
i_upload_manager &mgr);
|
||||
|
||||
private:
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi,
|
||||
std::map<std::uint64_t, open_file_data> open_data,
|
||||
i_provider &provider,
|
||||
std::optional<boost::dynamic_bitset<>> read_state,
|
||||
i_upload_manager &mgr);
|
||||
|
||||
public:
|
||||
open_file() = delete;
|
||||
open_file(const open_file &) noexcept = delete;
|
||||
open_file(open_file &&) noexcept = delete;
|
||||
auto operator=(open_file &&) noexcept -> open_file & = delete;
|
||||
auto operator=(const open_file &) noexcept -> open_file & = delete;
|
||||
|
||||
public:
|
||||
~open_file() override;
|
||||
|
||||
private:
|
||||
i_upload_manager &mgr_;
|
||||
|
||||
private:
|
||||
bool notified_ = false;
|
||||
std::size_t read_chunk_index_{};
|
||||
boost::dynamic_bitset<> read_state_;
|
||||
std::unique_ptr<std::thread> reader_thread_;
|
||||
std::unique_ptr<std::thread> download_thread_;
|
||||
stop_type stop_requested_ = false;
|
||||
|
||||
private:
|
||||
void download_chunk(std::size_t chunk, bool skip_active, bool should_reset);
|
||||
|
||||
void download_range(std::size_t start_chunk_index,
|
||||
std::size_t end_chunk_index_inclusive,
|
||||
bool should_reset);
|
||||
|
||||
void set_modified();
|
||||
|
||||
void update_background_reader(std::size_t read_chunk);
|
||||
|
||||
protected:
|
||||
auto is_download_complete() const -> bool override {
|
||||
return read_state_.all();
|
||||
}
|
||||
|
||||
public:
|
||||
auto close() -> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_read_state() const -> boost::dynamic_bitset<> override;
|
||||
|
||||
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_complete() const -> bool override;
|
||||
|
||||
auto is_write_supported() const -> bool override { return true; }
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(native_operation_callback callback) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(std::uint64_t new_file_size,
|
||||
native_operation_callback callback) -> api_error override;
|
||||
|
||||
void remove(std::uint64_t handle) override;
|
||||
|
||||
[[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset,
|
||||
data_buffer &data) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
resize(std::uint64_t new_file_size) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto write(std::uint64_t write_offset,
|
||||
const data_buffer &data,
|
||||
std::size_t &bytes_written) -> api_error override;
|
||||
};
|
||||
|
||||
class ring_buffer_open_file final : public open_file_base {
|
||||
public:
|
||||
ring_buffer_open_file(std::string buffer_directory,
|
||||
std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider);
|
||||
|
||||
ring_buffer_open_file(std::string buffer_directory,
|
||||
std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider,
|
||||
std::size_t ring_size);
|
||||
|
||||
~ring_buffer_open_file() override;
|
||||
|
||||
public:
|
||||
ring_buffer_open_file() = delete;
|
||||
ring_buffer_open_file(const ring_buffer_open_file &) noexcept = delete;
|
||||
ring_buffer_open_file(ring_buffer_open_file &&) noexcept = delete;
|
||||
auto operator=(ring_buffer_open_file &&) noexcept
|
||||
-> ring_buffer_open_file & = delete;
|
||||
auto operator=(const ring_buffer_open_file &) noexcept
|
||||
-> ring_buffer_open_file & = delete;
|
||||
|
||||
private:
|
||||
boost::dynamic_bitset<> ring_state_;
|
||||
std::size_t total_chunks_;
|
||||
|
||||
private:
|
||||
std::unique_ptr<std::thread> chunk_forward_thread_;
|
||||
std::unique_ptr<std::thread> chunk_reverse_thread_;
|
||||
std::condition_variable chunk_notify_;
|
||||
mutable std::mutex chunk_mtx_;
|
||||
std::size_t current_chunk_{};
|
||||
std::size_t first_chunk_{};
|
||||
std::size_t last_chunk_;
|
||||
|
||||
private:
|
||||
auto download_chunk(std::size_t chunk) -> api_error;
|
||||
|
||||
void forward_reader_thread(std::size_t count);
|
||||
|
||||
void reverse_reader_thread(std::size_t count);
|
||||
|
||||
protected:
|
||||
auto is_download_complete() const -> bool override;
|
||||
|
||||
public:
|
||||
void forward(std::size_t count);
|
||||
|
||||
[[nodiscard]] auto get_current_chunk() const -> std::size_t {
|
||||
return current_chunk_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_first_chunk() const -> std::size_t {
|
||||
return first_chunk_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_last_chunk() const -> std::size_t {
|
||||
return last_chunk_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_read_state() const -> boost::dynamic_bitset<> override;
|
||||
|
||||
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
|
||||
|
||||
[[nodiscard]] auto get_total_chunks() const -> std::size_t {
|
||||
return total_chunks_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_complete() const -> bool override { return true; }
|
||||
|
||||
auto is_write_supported() const -> bool override { return false; }
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(native_operation_callback callback) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(std::uint64_t,
|
||||
native_operation_callback) -> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset,
|
||||
data_buffer &data) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto resize(std::uint64_t) -> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
|
||||
void reverse(std::size_t count);
|
||||
|
||||
void set(std::size_t first_chunk, std::size_t current_chunk);
|
||||
|
||||
void set_api_path(const std::string &api_path) override;
|
||||
|
||||
[[nodiscard]] auto write(std::uint64_t, const data_buffer &,
|
||||
std::size_t &) -> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
};
|
||||
|
||||
class upload final {
|
||||
public:
|
||||
upload(filesystem_item fsi, i_provider &provider);
|
||||
|
||||
~upload();
|
||||
|
||||
public:
|
||||
upload() = delete;
|
||||
upload(const upload &) noexcept = delete;
|
||||
upload(upload &&) noexcept = delete;
|
||||
auto operator=(upload &&) noexcept -> upload & = delete;
|
||||
auto operator=(const upload &) noexcept -> upload & = delete;
|
||||
|
||||
private:
|
||||
filesystem_item fsi_;
|
||||
i_provider &provider_;
|
||||
|
||||
private:
|
||||
bool cancelled_{false};
|
||||
api_error error_{api_error::success};
|
||||
std::unique_ptr<std::thread> thread_;
|
||||
stop_type stop_requested_{false};
|
||||
|
||||
private:
|
||||
void upload_thread();
|
||||
|
||||
public:
|
||||
void cancel();
|
||||
|
||||
[[nodiscard]] auto get_api_error() const -> api_error { return error_; }
|
||||
|
||||
[[nodiscard]] auto get_api_path() const -> std::string {
|
||||
return fsi_.api_path;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_source_path() const -> std::string {
|
||||
return fsi_.source_path;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_cancelled() const -> bool { return cancelled_; }
|
||||
|
||||
void stop();
|
||||
};
|
||||
|
||||
public:
|
||||
file_manager(app_config &config, i_provider &provider);
|
||||
|
||||
@ -56,8 +452,8 @@ private:
|
||||
i_provider &provider_;
|
||||
|
||||
private:
|
||||
std::unique_ptr<i_file_mgr_db> mgr_db_;
|
||||
std::atomic<std::uint64_t> next_handle_{0U};
|
||||
db::db3_t db_{nullptr};
|
||||
std::uint64_t next_handle_{0U};
|
||||
mutable std::recursive_mutex open_file_mtx_;
|
||||
std::unordered_map<std::string, std::shared_ptr<i_closeable_open_file>>
|
||||
open_file_lookup_;
|
||||
@ -68,8 +464,6 @@ private:
|
||||
std::unique_ptr<std::thread> upload_thread_;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto close_all(const std::string &api_path) -> bool;
|
||||
|
||||
void close_timed_out_files();
|
||||
|
||||
auto get_open_file_by_handle(std::uint64_t handle) const
|
||||
@ -85,9 +479,6 @@ private:
|
||||
void queue_upload(const std::string &api_path, const std::string &source_path,
|
||||
bool no_lock);
|
||||
|
||||
void remove_resume(const std::string &api_path,
|
||||
const std::string &source_path, bool no_lock);
|
||||
|
||||
void remove_upload(const std::string &api_path, bool no_lock);
|
||||
|
||||
void swap_renamed_items(std::string from_api_path, std::string to_api_path,
|
||||
@ -108,11 +499,6 @@ public:
|
||||
void remove_resume(const std::string &api_path,
|
||||
const std::string &source_path) override;
|
||||
|
||||
static auto remove_source_and_shrink_cache(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
std::uint64_t file_size,
|
||||
bool allocated) -> bool;
|
||||
|
||||
void remove_upload(const std::string &api_path) override;
|
||||
|
||||
void store_resume(const i_open_file &file) override;
|
||||
@ -120,6 +506,8 @@ public:
|
||||
public:
|
||||
void close(std::uint64_t handle);
|
||||
|
||||
void close_all(const std::string &api_path);
|
||||
|
||||
[[nodiscard]] auto create(const std::string &api_path, api_meta_map &meta,
|
||||
open_file_data ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &file) -> api_error;
|
||||
@ -139,37 +527,38 @@ public:
|
||||
|
||||
[[nodiscard]] auto get_open_handle_count() const -> std::size_t;
|
||||
|
||||
[[nodiscard]] auto get_stored_downloads() const
|
||||
-> std::vector<i_file_mgr_db::resume_entry>;
|
||||
[[nodiscard]] auto get_stored_downloads() const -> std::vector<json>;
|
||||
|
||||
[[nodiscard]] auto has_no_open_file_handles() const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_processing(const std::string &api_path) const
|
||||
-> bool override;
|
||||
[[nodiscard]] auto
|
||||
is_processing(const std::string &api_path) const -> bool override;
|
||||
|
||||
#if defined(PROJECT_TESTING)
|
||||
[[nodiscard]] auto open(std::shared_ptr<i_closeable_open_file> of,
|
||||
const open_file_data &ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &file) -> api_error;
|
||||
#endif // defined(PROJECT_TESTING)
|
||||
#endif
|
||||
[[nodiscard]] auto open(const std::string &api_path, bool directory,
|
||||
const open_file_data &ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &file) -> api_error;
|
||||
|
||||
[[nodiscard]] auto remove_file(const std::string &api_path) -> api_error;
|
||||
|
||||
[[nodiscard]] auto rename_directory(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> api_error;
|
||||
[[nodiscard]] auto
|
||||
rename_directory(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> api_error;
|
||||
|
||||
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path, bool overwrite)
|
||||
-> api_error;
|
||||
const std::string &to_api_path,
|
||||
bool overwrite) -> api_error;
|
||||
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
|
||||
void update_used_space(std::uint64_t &used_space) const override;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
||||
#endif // INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_I_FILE_MANAGER_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_I_FILE_MANAGER_HPP_
|
||||
#ifndef INCLUDE_FILE_MANAGER_I_FILE_MANAGER_HPP_
|
||||
#define INCLUDE_FILE_MANAGER_I_FILE_MANAGER_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
@ -45,7 +45,9 @@ public:
|
||||
|
||||
[[nodiscard]] virtual auto is_processing(const std::string &api_path) const
|
||||
-> bool = 0;
|
||||
|
||||
virtual void update_used_space(std::uint64_t &used_space) const = 0;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_I_FILE_MANAGER_HPP_
|
||||
#endif // INCLUDE_FILE_MANAGER_I_FILE_MANAGER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_I_OPEN_FILE_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_I_OPEN_FILE_HPP_
|
||||
#ifndef INCLUDE_FILE_MANAGER_I_OPEN_FILE_HPP_
|
||||
#define INCLUDE_FILE_MANAGER_I_OPEN_FILE_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
@ -40,17 +40,11 @@ public:
|
||||
|
||||
[[nodiscard]] virtual auto get_filesystem_item() const -> filesystem_item = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_open_data()
|
||||
-> std::map<std::uint64_t, open_file_data> & = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_open_data() const
|
||||
-> const std::map<std::uint64_t, open_file_data> & = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_open_data(std::uint64_t handle)
|
||||
-> open_file_data & = 0;
|
||||
-> std::map<std::uint64_t, open_file_data> = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_open_data(std::uint64_t handle) const
|
||||
-> const open_file_data & = 0;
|
||||
-> open_file_data = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_open_file_count() const -> std::size_t = 0;
|
||||
|
||||
@ -62,12 +56,8 @@ public:
|
||||
|
||||
[[nodiscard]] virtual auto get_source_path() const -> std::string = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_complete() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_directory() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_write_supported() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto has_handle(std::uint64_t handle) const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
@ -97,8 +87,6 @@ class i_closeable_open_file : public i_open_file {
|
||||
public:
|
||||
virtual void add(std::uint64_t handle, open_file_data ofd) = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_allocated() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto can_close() const -> bool = 0;
|
||||
|
||||
virtual auto close() -> bool = 0;
|
||||
@ -106,12 +94,14 @@ public:
|
||||
[[nodiscard]] virtual auto get_handles() const
|
||||
-> std::vector<std::uint64_t> = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_complete() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_modified() const -> bool = 0;
|
||||
|
||||
virtual void remove(std::uint64_t handle) = 0;
|
||||
[[nodiscard]] virtual auto is_write_supported() const -> bool = 0;
|
||||
|
||||
virtual void remove_all() = 0;
|
||||
virtual void remove(std::uint64_t handle) = 0;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_I_OPEN_FILE_HPP_
|
||||
#endif // INCLUDE_FILE_MANAGER_I_OPEN_FILE_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_I_UPLOAD_MANAGER_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_I_UPLOAD_MANAGER_HPP_
|
||||
#ifndef INCLUDE_FILE_MANAGER_I_UPLOAD_MANAGER_HPP_
|
||||
#define INCLUDE_FILE_MANAGER_I_UPLOAD_MANAGER_HPP_
|
||||
|
||||
namespace repertory {
|
||||
class i_open_file;
|
||||
@ -29,15 +29,15 @@ class i_upload_manager {
|
||||
INTERFACE_SETUP(i_upload_manager);
|
||||
|
||||
public:
|
||||
virtual void queue_upload(const i_open_file &file) = 0;
|
||||
virtual void queue_upload(const i_open_file &o) = 0;
|
||||
|
||||
virtual void remove_resume(const std::string &api_path,
|
||||
const std::string &source_path) = 0;
|
||||
|
||||
virtual void remove_upload(const std::string &api_path) = 0;
|
||||
|
||||
virtual void store_resume(const i_open_file &file) = 0;
|
||||
virtual void store_resume(const i_open_file &o) = 0;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_I_UPLOAD_MANAGER_HPP_
|
||||
#endif // INCLUDE_FILE_MANAGER_I_UPLOAD_MANAGER_HPP_
|
||||
|
@ -1,135 +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 REPERTORY_INCLUDE_FILE_MANAGER_OPEN_FILE_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_OPEN_FILE_HPP_
|
||||
|
||||
#include "file_manager/open_file_base.hpp"
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/types/file/i_file.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class i_provider;
|
||||
class i_upload_manager;
|
||||
|
||||
class open_file final : public open_file_base {
|
||||
public:
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider, i_upload_manager &mgr);
|
||||
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi,
|
||||
std::map<std::uint64_t, open_file_data> open_data,
|
||||
i_provider &provider, i_upload_manager &mgr);
|
||||
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider,
|
||||
std::optional<boost::dynamic_bitset<>> read_state,
|
||||
i_upload_manager &mgr);
|
||||
|
||||
private:
|
||||
open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi,
|
||||
std::map<std::uint64_t, open_file_data> open_data,
|
||||
i_provider &provider,
|
||||
std::optional<boost::dynamic_bitset<>> read_state,
|
||||
i_upload_manager &mgr);
|
||||
|
||||
public:
|
||||
open_file() = delete;
|
||||
open_file(const open_file &) noexcept = delete;
|
||||
open_file(open_file &&) noexcept = delete;
|
||||
auto operator=(open_file &&) noexcept -> open_file & = delete;
|
||||
auto operator=(const open_file &) noexcept -> open_file & = delete;
|
||||
|
||||
public:
|
||||
~open_file() override;
|
||||
|
||||
private:
|
||||
i_upload_manager &mgr_;
|
||||
|
||||
private:
|
||||
bool allocated{false};
|
||||
std::unique_ptr<utils::file::i_file> nf_;
|
||||
bool notified_{false};
|
||||
std::size_t read_chunk_{};
|
||||
boost::dynamic_bitset<> read_state_;
|
||||
std::unique_ptr<std::thread> reader_thread_;
|
||||
mutable std::recursive_mutex rw_mtx_;
|
||||
stop_type stop_requested_{false};
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto adjust_cache_size(std::uint64_t file_size,
|
||||
bool shrink) -> api_error;
|
||||
|
||||
[[nodiscard]] auto check_start() -> api_error;
|
||||
|
||||
void download_chunk(std::size_t chunk, bool skip_active, bool should_reset);
|
||||
|
||||
void download_range(std::size_t begin_chunk, std::size_t end_chunk,
|
||||
bool should_reset);
|
||||
|
||||
void set_modified();
|
||||
|
||||
void set_read_state(std::size_t chunk);
|
||||
|
||||
void set_read_state(boost::dynamic_bitset<> read_state);
|
||||
|
||||
void update_reader(std::size_t chunk);
|
||||
|
||||
public:
|
||||
auto close() -> bool override;
|
||||
|
||||
[[nodiscard]] auto get_allocated() const -> bool override;
|
||||
|
||||
[[nodiscard]] auto get_read_state() const -> boost::dynamic_bitset<> override;
|
||||
|
||||
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_complete() const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_write_supported() const -> bool override {
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(native_operation_callback callback) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(std::uint64_t new_file_size,
|
||||
native_operation_callback callback) -> api_error override;
|
||||
|
||||
void remove(std::uint64_t handle) override;
|
||||
|
||||
void remove_all() override;
|
||||
|
||||
[[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset,
|
||||
data_buffer &data) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto resize(std::uint64_t new_file_size) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto write(std::uint64_t write_offset, const data_buffer &data,
|
||||
std::size_t &bytes_written) -> api_error override;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_OPEN_FILE_HPP_
|
@ -1,221 +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 REPERTORY_INCLUDE_FILE_MANAGER_OPEN_FILE_BASE_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_OPEN_FILE_BASE_HPP_
|
||||
|
||||
#include "file_manager/i_open_file.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class i_provider;
|
||||
|
||||
class open_file_base : public i_closeable_open_file {
|
||||
public:
|
||||
open_file_base(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider, bool disable_io);
|
||||
|
||||
open_file_base(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi,
|
||||
std::map<std::uint64_t, open_file_data> open_data,
|
||||
i_provider &provider, bool disable_io);
|
||||
|
||||
~open_file_base() override = default;
|
||||
|
||||
public:
|
||||
open_file_base() = delete;
|
||||
open_file_base(const open_file_base &) noexcept = delete;
|
||||
open_file_base(open_file_base &&) noexcept = delete;
|
||||
auto operator=(open_file_base &&) noexcept -> open_file_base & = delete;
|
||||
auto operator=(const open_file_base &) noexcept -> open_file_base & = delete;
|
||||
|
||||
public:
|
||||
class download final {
|
||||
public:
|
||||
download() = default;
|
||||
|
||||
~download() = default;
|
||||
|
||||
public:
|
||||
download(const download &) noexcept = delete;
|
||||
download(download &&) noexcept = delete;
|
||||
auto operator=(download &&) noexcept -> download & = delete;
|
||||
auto operator=(const download &) noexcept -> download & = delete;
|
||||
|
||||
private:
|
||||
bool complete_{false};
|
||||
api_error error_{api_error::success};
|
||||
std::mutex mtx_;
|
||||
std::condition_variable notify_;
|
||||
|
||||
public:
|
||||
void notify(const api_error &err);
|
||||
|
||||
auto wait() -> api_error;
|
||||
};
|
||||
|
||||
class io_item final {
|
||||
public:
|
||||
io_item(std::function<api_error()> action) : action_(std::move(action)) {}
|
||||
|
||||
~io_item() = default;
|
||||
|
||||
public:
|
||||
io_item() = delete;
|
||||
io_item(const io_item &) noexcept = delete;
|
||||
io_item(io_item &&) noexcept = delete;
|
||||
auto operator=(io_item &&) noexcept -> io_item & = delete;
|
||||
auto operator=(const io_item &) noexcept -> io_item & = delete;
|
||||
|
||||
private:
|
||||
std::function<api_error()> action_;
|
||||
std::mutex mtx_;
|
||||
std::condition_variable notify_;
|
||||
std::optional<api_error> result_;
|
||||
|
||||
public:
|
||||
void action();
|
||||
|
||||
[[nodiscard]] auto get_result() -> api_error;
|
||||
};
|
||||
|
||||
private:
|
||||
std::uint64_t chunk_size_;
|
||||
std::uint8_t chunk_timeout_;
|
||||
filesystem_item fsi_;
|
||||
std::size_t last_chunk_size_;
|
||||
std::map<std::uint64_t, open_file_data> open_data_;
|
||||
i_provider &provider_;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::size_t, std::shared_ptr<download>> active_downloads_;
|
||||
api_error error_{api_error::success};
|
||||
mutable std::mutex error_mtx_;
|
||||
mutable std::recursive_mutex file_mtx_;
|
||||
stop_type io_stop_requested_{false};
|
||||
std::unique_ptr<std::thread> io_thread_;
|
||||
mutable std::mutex io_thread_mtx_;
|
||||
std::condition_variable io_thread_notify_;
|
||||
std::deque<std::shared_ptr<io_item>> io_thread_queue_;
|
||||
std::atomic<std::chrono::system_clock::time_point> last_access_{
|
||||
std::chrono::system_clock::now(),
|
||||
};
|
||||
bool modified_{false};
|
||||
bool removed_{false};
|
||||
|
||||
private:
|
||||
void file_io_thread();
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto do_io(std::function<api_error()> action) -> api_error;
|
||||
|
||||
[[nodiscard]] auto get_active_downloads()
|
||||
-> std::unordered_map<std::size_t, std::shared_ptr<download>> & {
|
||||
return active_downloads_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_mutex() const -> std::recursive_mutex & {
|
||||
return file_mtx_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_last_chunk_size() const -> std::size_t;
|
||||
|
||||
[[nodiscard]] auto get_provider() -> i_provider & { return provider_; }
|
||||
|
||||
[[nodiscard]] auto get_provider() const -> const i_provider & {
|
||||
return provider_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_removed() const -> bool;
|
||||
|
||||
void notify_io();
|
||||
|
||||
void reset_timeout();
|
||||
|
||||
auto set_api_error(const api_error &err) -> api_error;
|
||||
|
||||
void set_file_size(std::uint64_t size);
|
||||
|
||||
void set_last_chunk_size(std::size_t size);
|
||||
|
||||
void set_modified(bool modified);
|
||||
|
||||
void set_removed(bool removed);
|
||||
|
||||
void set_source_path(std::string source_path);
|
||||
|
||||
void wait_for_io(stop_type &stop_requested);
|
||||
|
||||
public:
|
||||
void add(std::uint64_t handle, open_file_data ofd) override;
|
||||
|
||||
[[nodiscard]] auto can_close() const -> bool override;
|
||||
|
||||
auto close() -> bool override;
|
||||
|
||||
[[nodiscard]] auto get_allocated() const -> bool override { return false; }
|
||||
|
||||
[[nodiscard]] auto get_api_error() const -> api_error;
|
||||
|
||||
[[nodiscard]] auto get_api_path() const -> std::string override;
|
||||
|
||||
[[nodiscard]] auto get_chunk_size() const -> std::size_t override {
|
||||
return chunk_size_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_file_size() const -> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item() const -> filesystem_item override;
|
||||
|
||||
[[nodiscard]] auto get_handles() const -> std::vector<std::uint64_t> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_data() -> std::map<std::uint64_t, open_file_data> & override;
|
||||
|
||||
[[nodiscard]] auto get_open_data() const
|
||||
-> const std::map<std::uint64_t, open_file_data> & override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_data(std::uint64_t handle) -> open_file_data & override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_data(std::uint64_t handle) const -> const open_file_data & override;
|
||||
|
||||
[[nodiscard]] auto get_open_file_count() const -> std::size_t override;
|
||||
|
||||
[[nodiscard]] auto get_source_path() const -> std::string override;
|
||||
|
||||
[[nodiscard]] auto has_handle(std::uint64_t handle) const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_directory() const -> bool override {
|
||||
return fsi_.directory;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_modified() const -> bool override;
|
||||
|
||||
void remove(std::uint64_t handle) override;
|
||||
|
||||
void remove_all() override;
|
||||
|
||||
void set_api_path(const std::string &api_path) override;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_OPEN_FILE_BASE_HPP_
|
@ -1,150 +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 REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_BASE_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_BASE_HPP_
|
||||
|
||||
#include "file_manager/open_file_base.hpp"
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/file.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class i_provider;
|
||||
class i_upload_manager;
|
||||
|
||||
class ring_buffer_base : public open_file_base {
|
||||
public:
|
||||
ring_buffer_base(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||
filesystem_item fsi, i_provider &provider,
|
||||
std::size_t ring_size, bool disable_io);
|
||||
|
||||
~ring_buffer_base() override = default;
|
||||
|
||||
public:
|
||||
ring_buffer_base() = delete;
|
||||
ring_buffer_base(const ring_buffer_base &) noexcept = delete;
|
||||
ring_buffer_base(ring_buffer_base &&) noexcept = delete;
|
||||
auto operator=(ring_buffer_base &&) noexcept -> ring_buffer_base & = delete;
|
||||
auto
|
||||
operator=(const ring_buffer_base &) noexcept -> ring_buffer_base & = delete;
|
||||
|
||||
public:
|
||||
static constexpr const auto min_ring_size{5U};
|
||||
|
||||
private:
|
||||
boost::dynamic_bitset<> read_state_;
|
||||
std::size_t total_chunks_;
|
||||
|
||||
private:
|
||||
std::condition_variable chunk_notify_;
|
||||
mutable std::mutex chunk_mtx_;
|
||||
std::mutex read_mtx_;
|
||||
std::unique_ptr<std::thread> reader_thread_;
|
||||
std::size_t ring_begin_{};
|
||||
std::size_t ring_end_{};
|
||||
std::size_t ring_pos_{};
|
||||
stop_type stop_requested_{false};
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto check_start() -> api_error;
|
||||
|
||||
auto download_chunk(std::size_t chunk, bool skip_active) -> api_error;
|
||||
|
||||
void reader_thread();
|
||||
|
||||
void update_position(std::size_t count, bool is_forward);
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto has_reader_thread() const -> bool {
|
||||
return reader_thread_ != nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_ring_size() const -> std::size_t {
|
||||
return read_state_.size();
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual auto on_check_start() -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
on_chunk_downloaded(std::size_t chunk,
|
||||
const data_buffer &buffer) -> api_error = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
on_read_chunk(std::size_t chunk, std::size_t read_size,
|
||||
std::uint64_t read_offset, data_buffer &data,
|
||||
std::size_t &bytes_read) -> api_error = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
use_buffer(std::size_t chunk,
|
||||
std::function<api_error(data_buffer &)> func) -> api_error = 0;
|
||||
|
||||
public:
|
||||
auto close() -> bool override;
|
||||
|
||||
void forward(std::size_t count);
|
||||
|
||||
[[nodiscard]] auto get_current_chunk() const -> std::size_t {
|
||||
return ring_pos_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_first_chunk() const -> std::size_t {
|
||||
return ring_begin_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_last_chunk() const -> std::size_t { return ring_end_; }
|
||||
|
||||
[[nodiscard]] auto get_read_state() const -> boost::dynamic_bitset<> override;
|
||||
|
||||
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
|
||||
|
||||
[[nodiscard]] auto get_total_chunks() const -> std::size_t {
|
||||
return total_chunks_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_complete() const -> bool override { return false; }
|
||||
|
||||
[[nodiscard]] auto is_write_supported() const -> bool override {
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset,
|
||||
data_buffer &data) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto resize(std::uint64_t /* size */) -> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
|
||||
void reverse(std::size_t count);
|
||||
|
||||
void set(std::size_t first_chunk, std::size_t current_chunk);
|
||||
|
||||
void set_api_path(const std::string &api_path) override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
write(std::uint64_t /* write_offset */, const data_buffer & /* data */,
|
||||
std::size_t & /* bytes_written */) -> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_BASE_HPP_
|
@ -1,93 +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 REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_OPEN_FILE_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_OPEN_FILE_HPP_
|
||||
|
||||
#include "file_manager/ring_buffer_base.hpp"
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/file.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class i_provider;
|
||||
class i_upload_manager;
|
||||
|
||||
class ring_buffer_open_file final : public ring_buffer_base {
|
||||
public:
|
||||
ring_buffer_open_file(std::string buffer_directory, std::uint64_t chunk_size,
|
||||
std::uint8_t chunk_timeout, filesystem_item fsi,
|
||||
i_provider &provider, std::size_t ring_size);
|
||||
|
||||
~ring_buffer_open_file() override;
|
||||
|
||||
public:
|
||||
ring_buffer_open_file() = delete;
|
||||
ring_buffer_open_file(const ring_buffer_open_file &) noexcept = delete;
|
||||
ring_buffer_open_file(ring_buffer_open_file &&) noexcept = delete;
|
||||
auto operator=(ring_buffer_open_file &&) noexcept -> ring_buffer_open_file & =
|
||||
delete;
|
||||
auto operator=(const ring_buffer_open_file &) noexcept
|
||||
-> ring_buffer_open_file & = delete;
|
||||
|
||||
private:
|
||||
std::string source_path_;
|
||||
|
||||
private:
|
||||
std::unique_ptr<utils::file::i_file> nf_;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto on_check_start() -> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
on_chunk_downloaded(std::size_t chunk,
|
||||
const data_buffer &buffer) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
on_read_chunk(std::size_t chunk, std::size_t read_size,
|
||||
std::uint64_t read_offset, data_buffer &data,
|
||||
std::size_t &bytes_read) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto use_buffer(std::size_t chunk,
|
||||
std::function<api_error(data_buffer &)> func)
|
||||
-> api_error override;
|
||||
|
||||
public:
|
||||
[[nodiscard]] static auto can_handle_file(std::uint64_t file_size,
|
||||
std::size_t chunk_size,
|
||||
std::size_t ring_size) -> bool;
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(native_operation_callback callback) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto native_operation(std::uint64_t /* new_file_size */,
|
||||
native_operation_callback /* callback */)
|
||||
-> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_source_path() const -> std::string override {
|
||||
return source_path_;
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_OPEN_FILE_HPP_
|
@ -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 REPERTORY_INCLUDE_FILE_MANAGER_UPLOAD_HPP_
|
||||
#define REPERTORY_INCLUDE_FILE_MANAGER_UPLOAD_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class i_provider;
|
||||
|
||||
class upload final {
|
||||
public:
|
||||
upload(filesystem_item fsi, i_provider &provider);
|
||||
|
||||
~upload();
|
||||
|
||||
public:
|
||||
upload() = delete;
|
||||
upload(const upload &) noexcept = delete;
|
||||
upload(upload &&) noexcept = delete;
|
||||
auto operator=(upload &&) noexcept -> upload & = delete;
|
||||
auto operator=(const upload &) noexcept -> upload & = delete;
|
||||
|
||||
private:
|
||||
filesystem_item fsi_;
|
||||
i_provider &provider_;
|
||||
|
||||
private:
|
||||
bool cancelled_{false};
|
||||
api_error error_{api_error::success};
|
||||
std::unique_ptr<std::thread> thread_;
|
||||
stop_type stop_requested_{false};
|
||||
|
||||
private:
|
||||
void upload_thread();
|
||||
|
||||
public:
|
||||
void cancel();
|
||||
|
||||
[[nodiscard]] auto get_api_error() const -> api_error { return error_; }
|
||||
|
||||
[[nodiscard]] auto get_api_path() const -> std::string {
|
||||
return fsi_.api_path;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_source_path() const -> std::string {
|
||||
return fsi_.source_path;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_cancelled() const -> bool { return cancelled_; }
|
||||
|
||||
void stop();
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_UPLOAD_HPP_
|
@ -19,17 +19,14 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PLATFORM_PLATFORM_HPP_
|
||||
#define REPERTORY_INCLUDE_PLATFORM_PLATFORM_HPP_
|
||||
#ifndef INCLUDE_PLATFORM_PLATFORM_HPP_
|
||||
#define INCLUDE_PLATFORM_PLATFORM_HPP_
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "platform/win32_platform.hpp"
|
||||
#include "utils/windows.hpp"
|
||||
#include "utils/windows/windows_utils.hpp"
|
||||
#else // !defined(_WIN32)
|
||||
#include "platform/unix_platform.hpp"
|
||||
#include "platform/win32_platform.hpp"
|
||||
#include "utils/unix.hpp"
|
||||
#include "utils/unix/unix_utils.hpp"
|
||||
#endif // defined(_WIN32)
|
||||
#include "utils/windows.hpp"
|
||||
#include "utils/windows/windows_utils.hpp"
|
||||
|
||||
#endif // REPERTORY_INCLUDE_PLATFORM_PLATFORM_HPP_
|
||||
#endif // INCLUDE_PLATFORM_PLATFORM_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
|
||||
#define REPERTORY_INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
|
||||
#ifndef INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
|
||||
#define INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
@ -77,4 +77,4 @@ public:
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
|
||||
#endif // INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PLATFORM_WINPLATFORM_HPP_
|
||||
#define REPERTORY_INCLUDE_PLATFORM_WINPLATFORM_HPP_
|
||||
#ifndef INCLUDE_PLATFORM_WINPLATFORM_HPP_
|
||||
#define INCLUDE_PLATFORM_WINPLATFORM_HPP_
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "app_config.hpp"
|
||||
@ -83,4 +83,4 @@ public:
|
||||
} // namespace repertory
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // REPERTORY_INCLUDE_PLATFORM_WINPLATFORM_HPP_
|
||||
#endif // INCLUDE_PLATFORM_WINPLATFORM_HPP_
|
||||
|
@ -19,11 +19,11 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||
#define REPERTORY_INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||
#ifndef INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||
#define INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||
|
||||
#include "db/i_meta_db.hpp"
|
||||
#include "providers/i_provider.hpp"
|
||||
#include "providers/meta_db.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
@ -32,13 +32,6 @@ class i_file_manager;
|
||||
class i_http_comm;
|
||||
|
||||
class base_provider : public i_provider {
|
||||
private:
|
||||
struct removed_item final {
|
||||
std::string api_path;
|
||||
bool directory{};
|
||||
std::string source_path;
|
||||
};
|
||||
|
||||
public:
|
||||
base_provider(app_config &config, i_http_comm &comm)
|
||||
: config_(config), comm_(comm) {}
|
||||
@ -49,37 +42,24 @@ private:
|
||||
|
||||
private:
|
||||
api_item_added_callback api_item_added_;
|
||||
std::unique_ptr<i_meta_db> db3_;
|
||||
std::unique_ptr<meta_db> db3_;
|
||||
i_file_manager *fm_{};
|
||||
|
||||
private:
|
||||
void add_all_items(const stop_type &stop_requested);
|
||||
|
||||
void process_removed_directories(std::deque<removed_item> removed_list,
|
||||
const stop_type &stop_requested);
|
||||
|
||||
void process_removed_files(std::deque<removed_item> removed_list,
|
||||
const stop_type &stop_requested);
|
||||
|
||||
void process_removed_items(const stop_type &stop_requested);
|
||||
|
||||
void remove_deleted_items(const stop_type &stop_requested);
|
||||
|
||||
void remove_unmatched_source_files(const stop_type &stop_requested);
|
||||
void remove_deleted_files(bool source_only);
|
||||
|
||||
protected:
|
||||
[[nodiscard]] static auto create_api_file(std::string path, std::string key,
|
||||
std::uint64_t size,
|
||||
std::uint64_t file_time)
|
||||
-> api_file;
|
||||
[[nodiscard]] static auto
|
||||
create_api_file(std::string path, std::string key, std::uint64_t size,
|
||||
std::uint64_t file_time) -> api_file;
|
||||
|
||||
[[nodiscard]] static auto create_api_file(std::string path,
|
||||
std::uint64_t size,
|
||||
api_meta_map &meta) -> api_file;
|
||||
|
||||
[[nodiscard]] virtual auto create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta)
|
||||
-> api_error = 0;
|
||||
[[nodiscard]] virtual auto
|
||||
create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
create_file_extra(const std::string & /* api_path */,
|
||||
@ -91,14 +71,12 @@ protected:
|
||||
return api_item_added_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_api_item_added() const
|
||||
-> const api_item_added_callback & {
|
||||
[[nodiscard]] auto
|
||||
get_api_item_added() const -> const api_item_added_callback & {
|
||||
return api_item_added_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_comm() -> i_http_comm & { return comm_; }
|
||||
|
||||
[[nodiscard]] auto get_comm() const -> const i_http_comm & { return comm_; }
|
||||
[[nodiscard]] auto get_comm() const -> i_http_comm & { return comm_; }
|
||||
|
||||
[[nodiscard]] auto get_config() -> app_config & { return config_; }
|
||||
|
||||
@ -106,9 +84,7 @@ protected:
|
||||
return config_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_db() -> i_meta_db & { return *db3_; }
|
||||
|
||||
[[nodiscard]] auto get_db() const -> const i_meta_db & { return *db3_; }
|
||||
[[nodiscard]] auto get_db() -> meta_db & { return *db3_; }
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
get_directory_items_impl(const std::string &api_path,
|
||||
@ -120,22 +96,23 @@ protected:
|
||||
return fm_;
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual auto remove_directory_impl(const std::string &api_path)
|
||||
-> api_error = 0;
|
||||
[[nodiscard]] virtual auto
|
||||
get_used_drive_space_impl() const -> std::uint64_t = 0;
|
||||
|
||||
[[nodiscard]] virtual auto remove_file_impl(const std::string &api_path)
|
||||
-> api_error = 0;
|
||||
[[nodiscard]] virtual auto
|
||||
remove_directory_impl(const std::string &api_path) -> api_error = 0;
|
||||
|
||||
[[nodiscard]] virtual auto upload_file_impl(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
stop_type &stop_requested)
|
||||
-> api_error = 0;
|
||||
[[nodiscard]] virtual auto
|
||||
remove_file_impl(const std::string &api_path) -> api_error = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
upload_file_impl(const std::string &api_path, const std::string &source_path,
|
||||
stop_type &stop_requested) -> api_error = 0;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto
|
||||
create_directory_clone_source_meta(const std::string &source_api_path,
|
||||
const std::string &api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto create_directory_clone_source_meta(
|
||||
const std::string &source_api_path,
|
||||
const std::string &api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto create_directory(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error override;
|
||||
@ -143,83 +120,75 @@ public:
|
||||
[[nodiscard]] auto create_file(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_api_path_from_source(const std::string &source_path,
|
||||
std::string &api_path) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_directory_items(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_file_size(const std::string &api_path,
|
||||
std::uint64_t &file_size) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item(const std::string &api_path,
|
||||
bool directory,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item_and_file(const std::string &api_path,
|
||||
api_file &f,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
get_api_path_from_source(const std::string &source_path,
|
||||
std::string &api_path) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_filesystem_item_from_source_path(const std::string &source_path,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error override;
|
||||
get_directory_items(const std::string &api_path,
|
||||
directory_item_list &list) 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_file_size(const std::string &api_path,
|
||||
std::uint64_t &file_size) 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_filesystem_item(const std::string &api_path, bool directory,
|
||||
filesystem_item &fsi) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_pinned_files() const
|
||||
-> std::vector<std::string> override;
|
||||
[[nodiscard]] auto get_filesystem_item_and_file(
|
||||
const std::string &api_path, api_file &f,
|
||||
filesystem_item &fsi) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item_from_source_path(
|
||||
const std::string &source_path,
|
||||
filesystem_item &fsi) 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 &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_used_drive_space() const -> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto is_file_writeable(const std::string &api_path) const
|
||||
-> bool override;
|
||||
[[nodiscard]] auto
|
||||
is_file_writeable(const std::string &api_path) const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_read_only() const -> bool override { return false; }
|
||||
[[nodiscard]] auto
|
||||
remove_directory(const std::string &api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto remove_directory(const std::string &api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
remove_file(const std::string &api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto remove_file(const std::string &api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
remove_item_meta(const std::string &api_path,
|
||||
const std::string &key) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto remove_item_meta(const std::string &api_path,
|
||||
const std::string &key)
|
||||
-> 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 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;
|
||||
[[nodiscard]] auto
|
||||
set_item_meta(const std::string &api_path,
|
||||
const api_meta_map &meta) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto start(api_item_added_callback api_item_added,
|
||||
i_file_manager *mgr) -> bool override;
|
||||
|
||||
void stop() override;
|
||||
|
||||
[[nodiscard]] auto upload_file(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
stop_type &stop_requested)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
upload_file(const std::string &api_path, const std::string &source_path,
|
||||
stop_type &stop_requested) -> api_error override;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||
#endif // INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||
|
@ -19,11 +19,11 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_ENCRYPT_ENCRYPT_PROVIDER_HPP_
|
||||
#define REPERTORY_INCLUDE_PROVIDERS_ENCRYPT_ENCRYPT_PROVIDER_HPP_
|
||||
#ifndef INCLUDE_PROVIDERS_ENCRYPT_ENCRYPT_PROVIDER_HPP_
|
||||
#define INCLUDE_PROVIDERS_ENCRYPT_ENCRYPT_PROVIDER_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "db/i_file_db.hpp"
|
||||
#include "database/db_common.hpp"
|
||||
#include "providers/i_provider.hpp"
|
||||
#include "utils/encrypting_reader.hpp"
|
||||
|
||||
@ -45,22 +45,21 @@ public:
|
||||
|
||||
private:
|
||||
struct reader_info final {
|
||||
std::chrono::system_clock::time_point last_access_time{
|
||||
std::chrono::system_clock::now(),
|
||||
};
|
||||
std::unique_ptr<utils::encryption::encrypting_reader> reader;
|
||||
std::chrono::system_clock::time_point last_access_time =
|
||||
std::chrono::system_clock::now();
|
||||
std::unique_ptr<utils::encryption::encrypting_reader> reader{};
|
||||
std::mutex reader_mtx;
|
||||
};
|
||||
|
||||
private:
|
||||
app_config &config_;
|
||||
encrypt_config encrypt_config_;
|
||||
db::db3_t db_;
|
||||
|
||||
private:
|
||||
std::unique_ptr<i_file_db> db_{nullptr};
|
||||
i_file_manager *fm_{nullptr};
|
||||
std::unordered_map<std::string, std::shared_ptr<reader_info>> reader_lookup_;
|
||||
std::recursive_mutex reader_lookup_mtx_;
|
||||
i_file_manager *fm_ = nullptr;
|
||||
std::unordered_map<std::string, std::shared_ptr<reader_info>>
|
||||
reader_lookup_{};
|
||||
std::recursive_mutex reader_lookup_mtx_{};
|
||||
|
||||
private:
|
||||
static auto create_api_file(const std::string &api_path, bool directory,
|
||||
@ -74,82 +73,71 @@ private:
|
||||
const std::string &source_path)>
|
||||
callback) const -> api_error;
|
||||
|
||||
[[nodiscard]] auto get_encrypt_config() const -> const encrypt_config & {
|
||||
return encrypt_config_;
|
||||
}
|
||||
|
||||
auto process_directory_entry(const utils::file::i_fs_item &dir_entry,
|
||||
const encrypt_config &cfg,
|
||||
std::string &api_path) const -> bool;
|
||||
|
||||
void remove_deleted_files(const stop_type &stop_requested);
|
||||
void remove_deleted_files();
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto create_directory(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
create_directory_clone_source_meta(const std::string & /*source_api_path*/,
|
||||
const std::string & /*api_path*/)
|
||||
-> api_error override {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto create_file(const std::string & /*api_path*/,
|
||||
api_meta_map & /*meta*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto create_directory_clone_source_meta(
|
||||
const std::string & /*source_api_path*/,
|
||||
const std::string & /*api_path*/) -> api_error override {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_api_path_from_source(const std::string & /*source_path*/,
|
||||
std::string & /*api_path*/) const
|
||||
-> api_error override;
|
||||
create_file(const std::string & /*api_path*/,
|
||||
api_meta_map & /*meta*/) -> api_error override {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_api_path_from_source(
|
||||
const std::string & /*source_path*/,
|
||||
std::string & /*api_path*/) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
|
||||
-> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto get_directory_items(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
get_directory_items(const std::string &api_path,
|
||||
directory_item_list &list) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_file_list(api_file_list &list,
|
||||
std::string &marker) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_file_size(const std::string &api_path,
|
||||
std::uint64_t &file_size) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item(const std::string &api_path,
|
||||
bool directory,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item_and_file(const std::string &api_path,
|
||||
api_file &file,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto get_file(const std::string &api_path,
|
||||
api_file &file) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_filesystem_item_from_source_path(const std::string &source_path,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error override;
|
||||
get_file_list(api_file_list &list) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_pinned_files() const
|
||||
-> std::vector<std::string> override;
|
||||
[[nodiscard]] auto
|
||||
get_file_size(const std::string &api_path,
|
||||
std::uint64_t &file_size) 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_filesystem_item(const std::string &api_path, bool directory,
|
||||
filesystem_item &fsi) 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_filesystem_item_and_file(
|
||||
const std::string &api_path, api_file &file,
|
||||
filesystem_item &fsi) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item_from_source_path(
|
||||
const std::string &source_path,
|
||||
filesystem_item &fsi) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_pinned_files() 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_total_drive_space() const -> std::uint64_t override;
|
||||
|
||||
@ -161,61 +149,57 @@ public:
|
||||
|
||||
[[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto is_direct_only() const -> bool override { return true; }
|
||||
|
||||
[[nodiscard]] auto is_directory(const std::string &api_path,
|
||||
bool &exists) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto is_file(const std::string &api_path,
|
||||
bool &exists) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto is_file_writeable(const std::string &api_path) const
|
||||
-> bool override;
|
||||
[[nodiscard]] auto
|
||||
is_file_writeable(const std::string &api_path) const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_online() const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_read_only() const -> bool override { return true; }
|
||||
[[nodiscard]] auto is_rename_supported() const -> bool override;
|
||||
|
||||
[[nodiscard]] auto is_rename_supported() const -> bool override {
|
||||
return false;
|
||||
}
|
||||
[[nodiscard]] auto
|
||||
read_file_bytes(const std::string &api_path, std::size_t size,
|
||||
std::uint64_t offset, data_buffer &data,
|
||||
stop_type &stop_requested) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto read_file_bytes(const std::string &api_path,
|
||||
std::size_t size, std::uint64_t offset,
|
||||
data_buffer &data,
|
||||
stop_type &stop_requested)
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto remove_directory(const std::string & /*api_path*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto
|
||||
remove_directory(const std::string & /*api_path*/) -> api_error override {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto remove_file(const std::string & /*api_path*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto
|
||||
remove_file(const std::string & /*api_path*/) -> api_error override {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto remove_item_meta(const std::string & /*api_path*/,
|
||||
const std::string & /*key*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto
|
||||
remove_item_meta(const std::string & /*api_path*/,
|
||||
const std::string & /*key*/) -> api_error override {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto rename_file(const std::string & /*from_api_path*/,
|
||||
const std::string & /*to_api_path*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto
|
||||
rename_file(const std::string & /*from_api_path*/,
|
||||
const std::string & /*to_api_path*/) -> api_error override {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto set_item_meta(const std::string & /*api_path*/,
|
||||
const std::string & /*key*/,
|
||||
const std::string & /*value*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto
|
||||
set_item_meta(const std::string & /*api_path*/, const std::string & /*key*/,
|
||||
const std::string & /*value*/) -> api_error override {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto set_item_meta(const std::string & /*api_path*/,
|
||||
const api_meta_map & /*meta*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto
|
||||
set_item_meta(const std::string & /*api_path*/,
|
||||
const api_meta_map & /*meta*/) -> api_error override {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
@ -224,13 +208,13 @@ public:
|
||||
|
||||
void stop() override;
|
||||
|
||||
[[nodiscard]] auto upload_file(const std::string & /*api_path*/,
|
||||
const std::string & /*source_path*/,
|
||||
stop_type & /*stop_requested*/)
|
||||
-> api_error override {
|
||||
[[nodiscard]] auto
|
||||
upload_file(const std::string & /*api_path*/,
|
||||
const std::string & /*source_path*/,
|
||||
stop_type & /*stop_requested*/) -> api_error override {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_PROVIDERS_ENCRYPT_ENCRYPT_PROVIDER_HPP_
|
||||
#endif // INCLUDE_PROVIDERS_ENCRYPT_ENCRYPT_PROVIDER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_I_PROVIDER_HPP_
|
||||
#define REPERTORY_INCLUDE_PROVIDERS_I_PROVIDER_HPP_
|
||||
#ifndef INCLUDE_PROVIDERS_I_PROVIDER_HPP_
|
||||
#define INCLUDE_PROVIDERS_I_PROVIDER_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
@ -58,8 +58,7 @@ public:
|
||||
[[nodiscard]] virtual auto get_file(const std::string &api_path,
|
||||
api_file &file) const -> api_error = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_file_list(api_file_list &list,
|
||||
std::string &marker) const
|
||||
[[nodiscard]] virtual auto get_file_list(api_file_list &list) const
|
||||
-> api_error = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_file_size(const std::string &api_path,
|
||||
@ -100,6 +99,8 @@ public:
|
||||
|
||||
[[nodiscard]] virtual auto get_used_drive_space() const -> std::uint64_t = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_direct_only() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_directory(const std::string &api_path,
|
||||
bool &exists) const -> api_error = 0;
|
||||
|
||||
@ -111,8 +112,6 @@ public:
|
||||
|
||||
[[nodiscard]] virtual auto is_online() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_read_only() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto is_rename_supported() const -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
@ -155,4 +154,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_PROVIDERS_I_PROVIDER_HPP_
|
||||
#endif // INCLUDE_PROVIDERS_I_PROVIDER_HPP_
|
||||
|
@ -19,28 +19,27 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
|
||||
#ifndef INCLUDE_PROVIDERS_META_DB_HPP_
|
||||
#define INCLUDE_PROVIDERS_META_DB_HPP_
|
||||
|
||||
#include "db/i_meta_db.hpp"
|
||||
#include "database/db_common.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
|
||||
namespace repertory {
|
||||
class app_config;
|
||||
|
||||
class sqlite_meta_db final : public i_meta_db {
|
||||
class meta_db final {
|
||||
public:
|
||||
sqlite_meta_db(const app_config &cfg);
|
||||
~sqlite_meta_db() override;
|
||||
meta_db(const app_config &cfg);
|
||||
~meta_db();
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
private:
|
||||
utils::db::sqlite::db3_t db_;
|
||||
db::db3_t db_;
|
||||
constexpr static const auto table_name = "meta";
|
||||
|
||||
private:
|
||||
@ -48,50 +47,38 @@ private:
|
||||
api_meta_map meta) -> api_error;
|
||||
|
||||
public:
|
||||
void clear() override;
|
||||
|
||||
[[nodiscard]] auto get_api_path(const std::string &source_path,
|
||||
std::string &api_path) const
|
||||
-> api_error override;
|
||||
std::string &api_path) -> api_error;
|
||||
|
||||
[[nodiscard]] auto get_api_path_list() const
|
||||
-> std::vector<std::string> override;
|
||||
[[nodiscard]] auto get_api_path_list() -> std::vector<std::string>;
|
||||
|
||||
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
||||
api_meta_map &meta) const
|
||||
-> api_error override;
|
||||
api_meta_map &meta) -> api_error;
|
||||
|
||||
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
||||
const std::string &key,
|
||||
std::string &value) const
|
||||
-> api_error override;
|
||||
std::string &value) const -> api_error;
|
||||
|
||||
[[nodiscard]] auto get_pinned_files() const
|
||||
-> std::vector<std::string> override;
|
||||
[[nodiscard]] auto get_pinned_files() const -> std::vector<std::string>;
|
||||
|
||||
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override;
|
||||
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t;
|
||||
|
||||
[[nodiscard]] auto get_total_size() const -> std::uint64_t override;
|
||||
|
||||
void remove_api_path(const std::string &api_path) override;
|
||||
void remove_api_path(const std::string &api_path);
|
||||
|
||||
[[nodiscard]] auto remove_item_meta(const std::string &api_path,
|
||||
const std::string &key)
|
||||
-> api_error override;
|
||||
const std::string &key) -> api_error;
|
||||
|
||||
[[nodiscard]] auto rename_item_meta(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> api_error override;
|
||||
-> api_error;
|
||||
|
||||
[[nodiscard]] auto set_item_meta(const std::string &api_path,
|
||||
const std::string &key,
|
||||
const std::string &value)
|
||||
-> api_error override;
|
||||
const std::string &value) -> api_error;
|
||||
|
||||
[[nodiscard]] auto set_item_meta(const std::string &api_path,
|
||||
const api_meta_map &meta)
|
||||
-> api_error override;
|
||||
const api_meta_map &meta) -> api_error;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
|
||||
#endif // INCLUDE_PROVIDERS_META_DB_HPP_
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_PROVIDER_HPP_
|
||||
#define REPERTORY_INCLUDE_PROVIDERS_PROVIDER_HPP_
|
||||
#ifndef INCLUDE_PROVIDERS_PROVIDER_HPP_
|
||||
#define INCLUDE_PROVIDERS_PROVIDER_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
@ -28,9 +28,9 @@ namespace repertory {
|
||||
class app_config;
|
||||
class i_provider;
|
||||
|
||||
[[nodiscard]] auto
|
||||
create_provider(const provider_type &prov,
|
||||
app_config &config) -> std::unique_ptr<i_provider>;
|
||||
[[nodiscard]] auto create_provider(const provider_type &prov,
|
||||
app_config &config)
|
||||
-> std::unique_ptr<i_provider>;
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_PROVIDERS_PROVIDER_HPP_
|
||||
#endif // INCLUDE_PROVIDERS_PROVIDER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
#define REPERTORY_INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
#ifndef INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
#define INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
|
||||
#include "providers/base_provider.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -47,77 +47,69 @@ public:
|
||||
auto operator=(s3_provider &&) -> s3_provider & = delete;
|
||||
|
||||
private:
|
||||
s3_config s3_config_;
|
||||
[[nodiscard]] auto
|
||||
add_if_not_found(api_file &file,
|
||||
const std::string &object_name) const -> api_error;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto add_if_not_found(api_file &file,
|
||||
const std::string &object_name) const
|
||||
-> api_error;
|
||||
[[nodiscard]] auto
|
||||
create_file_extra(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto create_file_extra(const std::string &api_path,
|
||||
api_meta_map &meta)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
create_path_directories(const std::string &api_path,
|
||||
const std::string &key) const -> api_error;
|
||||
|
||||
[[nodiscard]] auto create_path_directories(const std::string &api_path,
|
||||
const std::string &key) const
|
||||
-> api_error;
|
||||
[[nodiscard]] auto
|
||||
decrypt_object_name(std::string &object_name) const -> api_error;
|
||||
|
||||
[[nodiscard]] auto decrypt_object_name(std::string &object_name) const
|
||||
-> api_error;
|
||||
|
||||
[[nodiscard]] auto get_last_modified(bool directory,
|
||||
const std::string &api_path) const
|
||||
-> std::uint64_t;
|
||||
[[nodiscard]] auto
|
||||
get_last_modified(bool directory,
|
||||
const std::string &api_path) const -> std::uint64_t;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_object_info(bool directory, const std::string &api_path,
|
||||
bool &is_encrypted, std::string &object_name,
|
||||
head_object_result &result) const -> api_error;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_object_list(std::string &response_data, long &response_code,
|
||||
std::optional<std::string> delimiter = std::nullopt,
|
||||
std::optional<std::string> prefix = std::nullopt,
|
||||
std::optional<std::string> token = std::nullopt) const
|
||||
-> bool;
|
||||
|
||||
[[nodiscard]] auto get_s3_config() const -> const s3_config & {
|
||||
return s3_config_;
|
||||
}
|
||||
[[nodiscard]] auto get_object_list(
|
||||
std::string &response_data, long &response_code,
|
||||
std::optional<std::string> delimiter = std::nullopt,
|
||||
std::optional<std::string> prefix = std::nullopt) const -> bool;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_directory_items_impl(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto remove_directory_impl(const std::string &api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
get_used_drive_space_impl() const -> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto remove_file_impl(const std::string &api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
remove_directory_impl(const std::string &api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto upload_file_impl(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
stop_type &stop_requested)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
remove_file_impl(const std::string &api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
upload_file_impl(const std::string &api_path, const std::string &source_path,
|
||||
stop_type &stop_requested) -> api_error override;
|
||||
|
||||
public:
|
||||
[[nodiscard]] static auto convert_api_date(std::string_view date)
|
||||
-> std::uint64_t;
|
||||
[[nodiscard]] static auto
|
||||
convert_api_date(std::string_view date) -> std::uint64_t;
|
||||
|
||||
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
|
||||
-> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto get_file(const std::string &api_path,
|
||||
api_file &file) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_file_list(api_file_list &list,
|
||||
std::string &marker) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
get_file_list(api_file_list &list) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
||||
|
||||
@ -125,11 +117,13 @@ public:
|
||||
return type;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto is_direct_only() const -> bool override { return false; }
|
||||
|
||||
[[nodiscard]] auto is_directory(const std::string &api_path,
|
||||
bool &exists) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto is_file(const std::string &api_path,
|
||||
bool &exists) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto is_online() const -> bool override;
|
||||
|
||||
@ -137,15 +131,14 @@ public:
|
||||
return false;
|
||||
};
|
||||
|
||||
[[nodiscard]] auto read_file_bytes(const std::string &api_path,
|
||||
std::size_t size, std::uint64_t offset,
|
||||
data_buffer &data,
|
||||
stop_type &stop_requested)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
read_file_bytes(const std::string &api_path, std::size_t size,
|
||||
std::uint64_t offset, data_buffer &data,
|
||||
stop_type &stop_requested) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto start(api_item_added_callback api_item_added,
|
||||
i_file_manager *mgr) -> bool override;
|
||||
@ -154,4 +147,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
#endif // INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_SIA_SIA_PROVIDER_HPP_
|
||||
#define REPERTORY_INCLUDE_PROVIDERS_SIA_SIA_PROVIDER_HPP_
|
||||
#ifndef INCLUDE_PROVIDERS_SIA_SIA_PROVIDER_HPP_
|
||||
#define INCLUDE_PROVIDERS_SIA_SIA_PROVIDER_HPP_
|
||||
|
||||
#include "providers/base_provider.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -45,9 +45,6 @@ public:
|
||||
auto operator=(const sia_provider &) -> sia_provider & = delete;
|
||||
auto operator=(sia_provider &&) -> sia_provider & = delete;
|
||||
|
||||
private:
|
||||
sia_config sia_config_;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto get_object_info(const std::string &api_path,
|
||||
json &object_info) const -> api_error;
|
||||
@ -55,40 +52,37 @@ private:
|
||||
[[nodiscard]] auto get_object_list(const std::string &api_path,
|
||||
nlohmann::json &object_list) const -> bool;
|
||||
|
||||
[[nodiscard]] auto get_sia_config() const -> const auto & {
|
||||
return sia_config_;
|
||||
}
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_directory_items_impl(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto remove_directory_impl(const std::string &api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
get_used_drive_space_impl() const -> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto remove_file_impl(const std::string &api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
remove_directory_impl(const std::string &api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto upload_file_impl(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
stop_type &stop_requested)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
remove_file_impl(const std::string &api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
upload_file_impl(const std::string &api_path, const std::string &source_path,
|
||||
stop_type &stop_requested) -> api_error override;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
|
||||
-> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto get_file(const std::string &api_path,
|
||||
api_file &file) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_file_list(api_file_list &list,
|
||||
std::string &marker) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
get_file_list(api_file_list &list) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto get_provider_type() const -> provider_type override {
|
||||
return type;
|
||||
@ -96,11 +90,13 @@ public:
|
||||
|
||||
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
||||
|
||||
[[nodiscard]] auto is_direct_only() const -> bool override { return false; }
|
||||
|
||||
[[nodiscard]] auto is_directory(const std::string &api_path,
|
||||
bool &exists) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto is_file(const std::string &api_path,
|
||||
bool &exists) const -> api_error override;
|
||||
|
||||
[[nodiscard]] auto is_online() const -> bool override;
|
||||
|
||||
@ -108,15 +104,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto read_file_bytes(const std::string &api_path,
|
||||
std::size_t size, std::uint64_t offset,
|
||||
data_buffer &buffer,
|
||||
stop_type &stop_requested)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
read_file_bytes(const std::string &api_path, std::size_t size,
|
||||
std::uint64_t offset, data_buffer &buffer,
|
||||
stop_type &stop_requested) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> api_error override;
|
||||
[[nodiscard]] auto
|
||||
rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto start(api_item_added_callback api_item_added,
|
||||
i_file_manager *mgr) -> bool override;
|
||||
@ -125,4 +120,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_PROVIDERS_SIA_SIA_PROVIDER_HPP_
|
||||
#endif // INCLUDE_PROVIDERS_SIA_SIA_PROVIDER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_RPC_CLIENT_CLIENT_HPP_
|
||||
#define REPERTORY_INCLUDE_RPC_CLIENT_CLIENT_HPP_
|
||||
#ifndef INCLUDE_RPC_CLIENT_CLIENT_HPP_
|
||||
#define INCLUDE_RPC_CLIENT_CLIENT_HPP_
|
||||
|
||||
#include "types/rpc.hpp"
|
||||
|
||||
@ -38,11 +38,11 @@ public:
|
||||
|
||||
[[nodiscard]] auto get_config() -> rpc_response;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_config_value_by_name(const std::string &name) -> rpc_response;
|
||||
[[nodiscard]] auto get_config_value_by_name(const std::string &name)
|
||||
-> rpc_response;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_directory_items(const std::string &api_path) -> rpc_response;
|
||||
[[nodiscard]] auto get_directory_items(const std::string &api_path)
|
||||
-> rpc_response;
|
||||
|
||||
[[nodiscard]] auto get_open_files() -> rpc_response;
|
||||
|
||||
@ -52,9 +52,9 @@ public:
|
||||
|
||||
[[nodiscard]] auto pinned_status(const std::string &api_file) -> rpc_response;
|
||||
|
||||
[[nodiscard]] auto
|
||||
set_config_value_by_name(const std::string &name,
|
||||
const std::string &value) -> rpc_response;
|
||||
[[nodiscard]] auto set_config_value_by_name(const std::string &name,
|
||||
const std::string &value)
|
||||
-> rpc_response;
|
||||
|
||||
[[nodiscard]] auto unmount() -> rpc_response;
|
||||
|
||||
@ -62,4 +62,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_RPC_CLIENT_CLIENT_HPP_
|
||||
#endif // INCLUDE_RPC_CLIENT_CLIENT_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_RPC_SERVER_FULL_SERVER_HPP_
|
||||
#define REPERTORY_INCLUDE_RPC_SERVER_FULL_SERVER_HPP_
|
||||
#ifndef INCLUDE_RPC_SERVER_FULL_SERVER_HPP_
|
||||
#define INCLUDE_RPC_SERVER_FULL_SERVER_HPP_
|
||||
|
||||
#include "rpc/server/server.hpp"
|
||||
|
||||
@ -64,4 +64,4 @@ protected:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_RPC_SERVER_FULL_SERVER_HPP_
|
||||
#endif // INCLUDE_RPC_SERVER_FULL_SERVER_HPP_
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_RPC_SERVER_SERVER_HPP_
|
||||
#define REPERTORY_INCLUDE_RPC_SERVER_SERVER_HPP_
|
||||
#ifndef INCLUDE_RPC_SERVER_SERVER_HPP_
|
||||
#define INCLUDE_RPC_SERVER_SERVER_HPP_
|
||||
|
||||
#include "types/rpc.hpp"
|
||||
|
||||
@ -72,4 +72,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_RPC_SERVER_SERVER_HPP_
|
||||
#endif // INCLUDE_RPC_SERVER_SERVER_HPP_
|
||||
|
@ -19,10 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_TYPES_REMOTE_HPP_
|
||||
#define REPERTORY_INCLUDE_TYPES_REMOTE_HPP_
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
#ifndef INCLUDE_TYPES_REMOTE_HPP_
|
||||
#define INCLUDE_TYPES_REMOTE_HPP_
|
||||
|
||||
inline constexpr const auto PACKET_SERVICE_FUSE{1U};
|
||||
inline constexpr const auto PACKET_SERVICE_WINFSP{2U};
|
||||
@ -33,67 +31,7 @@ inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_WINFSP};
|
||||
inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_FUSE};
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
constexpr const auto default_remote_client_pool_size{20U};
|
||||
constexpr const auto default_remote_max_connections{20U};
|
||||
constexpr const auto default_remote_receive_timeout_ms{120U * 1000U};
|
||||
constexpr const auto default_remote_send_timeout_ms{30U * 1000U};
|
||||
|
||||
namespace repertory::remote {
|
||||
struct remote_config final {
|
||||
std::uint16_t api_port{};
|
||||
std::string encryption_token;
|
||||
std::string host_name_or_ip;
|
||||
std::uint8_t max_connections{default_remote_max_connections};
|
||||
std::uint32_t recv_timeout_ms{default_remote_receive_timeout_ms};
|
||||
std::uint32_t send_timeout_ms{default_remote_send_timeout_ms};
|
||||
|
||||
auto operator==(const remote_config &cfg) const noexcept -> bool {
|
||||
if (&cfg != this) {
|
||||
return api_port == cfg.api_port &&
|
||||
encryption_token == cfg.encryption_token &&
|
||||
host_name_or_ip == cfg.host_name_or_ip &&
|
||||
max_connections == cfg.max_connections &&
|
||||
recv_timeout_ms == cfg.recv_timeout_ms &&
|
||||
send_timeout_ms == cfg.send_timeout_ms;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto operator!=(const remote_config &cfg) const noexcept -> bool {
|
||||
if (&cfg != this) {
|
||||
return not(cfg == *this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct remote_mount final {
|
||||
std::uint16_t api_port{};
|
||||
std::uint8_t client_pool_size{default_remote_client_pool_size};
|
||||
bool enable{false};
|
||||
std::string encryption_token;
|
||||
|
||||
auto operator==(const remote_mount &cfg) const noexcept -> bool {
|
||||
if (&cfg == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return api_port == cfg.api_port &&
|
||||
client_pool_size == cfg.client_pool_size && enable == cfg.enable &&
|
||||
encryption_token == cfg.encryption_token;
|
||||
}
|
||||
|
||||
auto operator!=(const remote_mount &cfg) const noexcept -> bool {
|
||||
if (&cfg == this) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return not(cfg == *this);
|
||||
}
|
||||
};
|
||||
|
||||
using block_count = std::uint64_t;
|
||||
using block_size = std::uint32_t;
|
||||
using file_handle = std::uint64_t;
|
||||
@ -222,46 +160,4 @@ create_os_open_flags(const open_flags &flags) -> std::uint32_t;
|
||||
#endif // !defined(_WIN32)
|
||||
} // namespace repertory::remote
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::remote::remote_config> {
|
||||
static void to_json(json &data,
|
||||
const repertory::remote::remote_config &value) {
|
||||
data[repertory::JSON_API_PORT] = value.api_port;
|
||||
data[repertory::JSON_ENCRYPTION_TOKEN] = value.encryption_token;
|
||||
data[repertory::JSON_HOST_NAME_OR_IP] = value.host_name_or_ip;
|
||||
data[repertory::JSON_MAX_CONNECTIONS] = value.max_connections;
|
||||
data[repertory::JSON_RECV_TIMEOUT_MS] = value.recv_timeout_ms;
|
||||
data[repertory::JSON_SEND_TIMEOUT_MS] = value.send_timeout_ms;
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
repertory::remote::remote_config &value) {
|
||||
data.at(repertory::JSON_API_PORT).get_to(value.api_port);
|
||||
data.at(repertory::JSON_ENCRYPTION_TOKEN).get_to(value.encryption_token);
|
||||
data.at(repertory::JSON_HOST_NAME_OR_IP).get_to(value.host_name_or_ip);
|
||||
data.at(repertory::JSON_MAX_CONNECTIONS).get_to(value.max_connections);
|
||||
data.at(repertory::JSON_RECV_TIMEOUT_MS).get_to(value.recv_timeout_ms);
|
||||
data.at(repertory::JSON_SEND_TIMEOUT_MS).get_to(value.send_timeout_ms);
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct adl_serializer<repertory::remote::remote_mount> {
|
||||
static void to_json(json &data,
|
||||
const repertory::remote::remote_mount &value) {
|
||||
data[repertory::JSON_API_PORT] = value.api_port;
|
||||
data[repertory::JSON_CLIENT_POOL_SIZE] = value.client_pool_size;
|
||||
data[repertory::JSON_ENABLE_REMOTE_MOUNT] = value.enable;
|
||||
data[repertory::JSON_ENCRYPTION_TOKEN] = value.encryption_token;
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
repertory::remote::remote_mount &value) {
|
||||
data.at(repertory::JSON_API_PORT).get_to(value.api_port);
|
||||
data.at(repertory::JSON_CLIENT_POOL_SIZE).get_to(value.client_pool_size);
|
||||
data.at(repertory::JSON_ENABLE_REMOTE_MOUNT).get_to(value.enable);
|
||||
data.at(repertory::JSON_ENCRYPTION_TOKEN).get_to(value.encryption_token);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // REPERTORY_INCLUDE_TYPES_REMOTE_HPP_
|
||||
#endif // INCLUDE_TYPES_REMOTE_HPP_
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user