refactor file system operations
the most notable improvement is that uploads are now using streams so they no longer require the entire file to be stored in memory
This commit is contained in:
478
backend/Cargo.lock
generated
478
backend/Cargo.lock
generated
@@ -17,17 +17,6 @@ version = "2.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ahash"
|
|
||||||
version = "0.7.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom 0.2.16",
|
|
||||||
"once_cell",
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "1.1.3"
|
version = "1.1.3"
|
||||||
@@ -76,23 +65,6 @@ dependencies = [
|
|||||||
"password-hash",
|
"password-hash",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arrayvec"
|
|
||||||
version = "0.7.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-trait"
|
|
||||||
version = "0.1.88"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.104",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atoi"
|
name = "atoi"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@@ -164,38 +136,27 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum_typed_multipart"
|
name = "axum-extra"
|
||||||
version = "0.16.3"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7915d0c957ffd1a28edd7dff1f6d7b79c80e519b19b0961a8c80423504c45a82"
|
checksum = "45bf463831f5131b7d3c756525b305d40f1185b688565648a92e1392ca35713d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"async-trait",
|
|
||||||
"axum",
|
"axum",
|
||||||
"axum_typed_multipart_macros",
|
"axum-core",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"fastrand",
|
||||||
"futures-core",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"rust_decimal",
|
"http",
|
||||||
"tempfile",
|
"http-body",
|
||||||
"thiserror",
|
"http-body-util",
|
||||||
"tokio",
|
"mime",
|
||||||
"uuid",
|
"multer",
|
||||||
]
|
"pin-project-lite",
|
||||||
|
"rustversion",
|
||||||
[[package]]
|
"serde",
|
||||||
name = "axum_typed_multipart_macros"
|
"tower",
|
||||||
version = "0.16.3"
|
"tower-layer",
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
"tower-service",
|
||||||
checksum = "cc9e427c074d9f5355a2a7d969cf3a48dde6bf888b120937fb4c96ad2604b48a"
|
|
||||||
dependencies = [
|
|
||||||
"darling",
|
|
||||||
"heck",
|
|
||||||
"proc-macro-error2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.104",
|
|
||||||
"ubyte",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -234,18 +195,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitvec"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
|
|
||||||
dependencies = [
|
|
||||||
"funty",
|
|
||||||
"radium",
|
|
||||||
"tap",
|
|
||||||
"wyz",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blake2"
|
name = "blake2"
|
||||||
version = "0.10.6"
|
version = "0.10.6"
|
||||||
@@ -264,57 +213,12 @@ dependencies = [
|
|||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "borsh"
|
|
||||||
version = "1.5.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce"
|
|
||||||
dependencies = [
|
|
||||||
"borsh-derive",
|
|
||||||
"cfg_aliases",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "borsh-derive"
|
|
||||||
version = "1.5.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3"
|
|
||||||
dependencies = [
|
|
||||||
"once_cell",
|
|
||||||
"proc-macro-crate",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.104",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.19.0"
|
version = "3.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bytecheck"
|
|
||||||
version = "0.6.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2"
|
|
||||||
dependencies = [
|
|
||||||
"bytecheck_derive",
|
|
||||||
"ptr_meta",
|
|
||||||
"simdutf8",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bytecheck_derive"
|
|
||||||
version = "0.6.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@@ -342,12 +246,6 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg_aliases"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.41"
|
version = "0.4.41"
|
||||||
@@ -432,41 +330,6 @@ dependencies = [
|
|||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "darling"
|
|
||||||
version = "0.20.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
|
|
||||||
dependencies = [
|
|
||||||
"darling_core",
|
|
||||||
"darling_macro",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "darling_core"
|
|
||||||
version = "0.20.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e"
|
|
||||||
dependencies = [
|
|
||||||
"fnv",
|
|
||||||
"ident_case",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"strsim",
|
|
||||||
"syn 2.0.104",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "darling_macro"
|
|
||||||
version = "0.20.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
|
|
||||||
dependencies = [
|
|
||||||
"darling_core",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.104",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "der"
|
name = "der"
|
||||||
version = "0.7.10"
|
version = "0.7.10"
|
||||||
@@ -504,7 +367,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -528,7 +391,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -637,12 +500,6 @@ dependencies = [
|
|||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "funty"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-channel"
|
name = "futures-channel"
|
||||||
version = "0.3.31"
|
version = "0.3.31"
|
||||||
@@ -695,7 +552,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -745,19 +602,7 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
"wasi",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "getrandom"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"r-efi",
|
|
||||||
"wasi 0.14.2+wasi-0.2.4",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -766,15 +611,6 @@ version = "0.31.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hashbrown"
|
|
||||||
version = "0.12.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
|
||||||
dependencies = [
|
|
||||||
"ahash",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.15.4"
|
version = "0.15.4"
|
||||||
@@ -792,7 +628,7 @@ version = "0.10.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.15.4",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1031,12 +867,6 @@ dependencies = [
|
|||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ident_case"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
@@ -1065,7 +895,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
|
checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.15.4",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1208,7 +1038,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
"wasi",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1431,37 +1261,6 @@ dependencies = [
|
|||||||
"zerocopy",
|
"zerocopy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro-crate"
|
|
||||||
version = "3.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"
|
|
||||||
dependencies = [
|
|
||||||
"toml_edit",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro-error-attr2"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro-error2"
|
|
||||||
version = "2.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro-error-attr2",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.104",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.95"
|
version = "1.0.95"
|
||||||
@@ -1471,26 +1270,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ptr_meta"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1"
|
|
||||||
dependencies = [
|
|
||||||
"ptr_meta_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ptr_meta_derive"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.40"
|
version = "1.0.40"
|
||||||
@@ -1500,18 +1279,6 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "r-efi"
|
|
||||||
version = "5.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "radium"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
@@ -1539,7 +1306,7 @@ version = "0.6.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.16",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1580,44 +1347,6 @@ version = "0.8.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rend"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c"
|
|
||||||
dependencies = [
|
|
||||||
"bytecheck",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rkyv"
|
|
||||||
version = "0.7.45"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b"
|
|
||||||
dependencies = [
|
|
||||||
"bitvec",
|
|
||||||
"bytecheck",
|
|
||||||
"bytes",
|
|
||||||
"hashbrown 0.12.3",
|
|
||||||
"ptr_meta",
|
|
||||||
"rend",
|
|
||||||
"rkyv_derive",
|
|
||||||
"seahash",
|
|
||||||
"tinyvec",
|
|
||||||
"uuid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rkyv_derive"
|
|
||||||
version = "0.7.45"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rsa"
|
name = "rsa"
|
||||||
version = "0.9.8"
|
version = "0.9.8"
|
||||||
@@ -1638,22 +1367,6 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rust_decimal"
|
|
||||||
version = "1.37.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b203a6425500a03e0919c42d3c47caca51e79f1132046626d2c8871c5092035d"
|
|
||||||
dependencies = [
|
|
||||||
"arrayvec",
|
|
||||||
"borsh",
|
|
||||||
"bytes",
|
|
||||||
"num-traits",
|
|
||||||
"rand",
|
|
||||||
"rkyv",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.25"
|
version = "0.1.25"
|
||||||
@@ -1691,12 +1404,6 @@ version = "1.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "seahash"
|
|
||||||
version = "4.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.219"
|
version = "1.0.219"
|
||||||
@@ -1714,7 +1421,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1807,12 +1514,6 @@ dependencies = [
|
|||||||
"rand_core",
|
"rand_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "simdutf8"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.10"
|
version = "0.4.10"
|
||||||
@@ -1887,7 +1588,7 @@ dependencies = [
|
|||||||
"futures-intrusive",
|
"futures-intrusive",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hashbrown 0.15.4",
|
"hashbrown",
|
||||||
"hashlink",
|
"hashlink",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"log",
|
"log",
|
||||||
@@ -1917,7 +1618,7 @@ dependencies = [
|
|||||||
"quote",
|
"quote",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"sqlx-macros-core",
|
"sqlx-macros-core",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1940,7 +1641,7 @@ dependencies = [
|
|||||||
"sqlx-mysql",
|
"sqlx-mysql",
|
||||||
"sqlx-postgres",
|
"sqlx-postgres",
|
||||||
"sqlx-sqlite",
|
"sqlx-sqlite",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
@@ -2074,29 +1775,12 @@ dependencies = [
|
|||||||
"unicode-properties",
|
"unicode-properties",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strsim"
|
|
||||||
version = "0.11.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.6.1"
|
version = "2.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.109"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.104"
|
version = "2.0.104"
|
||||||
@@ -2122,26 +1806,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tap"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tempfile"
|
|
||||||
version = "3.20.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
|
|
||||||
dependencies = [
|
|
||||||
"fastrand",
|
|
||||||
"getrandom 0.3.3",
|
|
||||||
"once_cell",
|
|
||||||
"rustix",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2161,7 +1826,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2257,7 +1922,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2284,23 +1949,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "toml_datetime"
|
|
||||||
version = "0.6.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "toml_edit"
|
|
||||||
version = "0.22.27"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
|
|
||||||
dependencies = [
|
|
||||||
"indexmap",
|
|
||||||
"toml_datetime",
|
|
||||||
"winnow",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower"
|
name = "tower"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
@@ -2375,7 +2023,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2419,12 +2067,6 @@ version = "1.18.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
|
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ubyte"
|
|
||||||
version = "0.10.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f720def6ce1ee2fc44d40ac9ed6d3a59c361c80a75a7aa8e75bb9baed31cf2ea"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicase"
|
name = "unicase"
|
||||||
version = "2.8.1"
|
version = "2.8.1"
|
||||||
@@ -2517,11 +2159,13 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"argon2",
|
"argon2",
|
||||||
"axum",
|
"axum",
|
||||||
"axum_typed_multipart",
|
"axum-extra",
|
||||||
"base64",
|
"base64",
|
||||||
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
"futures-util",
|
||||||
"hex",
|
"hex",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"regex",
|
"regex",
|
||||||
@@ -2545,15 +2189,6 @@ version = "0.11.1+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.14.2+wasi-0.2.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
|
||||||
dependencies = [
|
|
||||||
"wit-bindgen-rt",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasite"
|
name = "wasite"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -2582,7 +2217,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2604,7 +2239,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
@@ -2671,7 +2306,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2682,7 +2317,7 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2857,39 +2492,12 @@ version = "0.52.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winnow"
|
|
||||||
version = "0.7.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wit-bindgen-rt"
|
|
||||||
version = "0.39.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "writeable"
|
name = "writeable"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
|
checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wyz"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
|
|
||||||
dependencies = [
|
|
||||||
"tap",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yoke"
|
name = "yoke"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
@@ -2910,7 +2518,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2931,7 +2539,7 @@ checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2951,7 +2559,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2991,5 +2599,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ path = "src/bin/backend/main.rs"
|
|||||||
anyhow = "1.0.98"
|
anyhow = "1.0.98"
|
||||||
argon2 = "0.5.3"
|
argon2 = "0.5.3"
|
||||||
axum = { version = "0.8.4", features = ["multipart", "query"] }
|
axum = { version = "0.8.4", features = ["multipart", "query"] }
|
||||||
axum_typed_multipart = "0.16.3"
|
axum-extra = { version = "0.10.1", features = ["multipart"] }
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
|
bytes = "1.10.1"
|
||||||
chrono = "0.4.41"
|
chrono = "0.4.41"
|
||||||
derive_more = { version = "2.0.1", features = ["display"] }
|
derive_more = { version = "2.0.1", features = ["display"] }
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
|
futures-util = "0.3.31"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use derive_more::Display;
|
use derive_more::Display;
|
||||||
use requests::FetchAuthSessionError;
|
use requests::{FetchAuthSessionError, FetchAuthSessionRequest};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@@ -145,6 +145,16 @@ impl<T> AuthRequest<T> {
|
|||||||
pub fn unpack(self) -> (AuthSessionIdWithType, T) {
|
pub fn unpack(self) -> (AuthSessionIdWithType, T) {
|
||||||
(self.auth, self.value)
|
(self.auth, self.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_value(self) -> T {
|
||||||
|
self.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> From<&AuthRequest<T>> for FetchAuthSessionRequest {
|
||||||
|
fn from(value: &AuthRequest<T>) -> Self {
|
||||||
|
FetchAuthSessionRequest::new(value.auth().session_id().clone())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
|
|||||||
@@ -126,8 +126,14 @@ impl FilePath {
|
|||||||
|
|
||||||
pub fn join(&self, other: &RelativeFilePath) -> Self {
|
pub fn join(&self, other: &RelativeFilePath) -> Self {
|
||||||
let mut path = self.0.clone();
|
let mut path = self.0.clone();
|
||||||
path.push('/');
|
|
||||||
path.push_str(&other.0);
|
if !other.0.is_empty() {
|
||||||
|
if path != "/" {
|
||||||
|
path.push('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
path.push_str(&other.0);
|
||||||
|
}
|
||||||
|
|
||||||
Self(path)
|
Self(path)
|
||||||
}
|
}
|
||||||
@@ -173,7 +179,9 @@ impl AbsoluteFilePath {
|
|||||||
|
|
||||||
pub fn join(mut self, other: &RelativeFilePath) -> Self {
|
pub fn join(mut self, other: &RelativeFilePath) -> Self {
|
||||||
if !other.0.is_empty() {
|
if !other.0.is_empty() {
|
||||||
self.0.push('/');
|
if self.0 != "/" {
|
||||||
|
self.0.push('/');
|
||||||
|
}
|
||||||
self.0.push_str(&other.0);
|
self.0.push_str(&other.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,175 +0,0 @@
|
|||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
use super::{AbsoluteFilePath, FileName};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct ListFilesRequest {
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ListFilesRequest {
|
|
||||||
pub fn new(path: AbsoluteFilePath) -> Self {
|
|
||||||
Self { path }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum ListFilesError {
|
|
||||||
#[error("Directory at path {0} does not exist")]
|
|
||||||
NotFound(String),
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct DeleteDirectoryRequest {
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
force: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct DeleteFileRequest {
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DeleteDirectoryRequest {
|
|
||||||
pub fn new(path: AbsoluteFilePath, force: bool) -> Self {
|
|
||||||
Self { path, force }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn force(&self) -> bool {
|
|
||||||
self.force
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DeleteFileRequest {
|
|
||||||
pub fn new(path: AbsoluteFilePath) -> Self {
|
|
||||||
Self { path }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum DeleteDirectoryError {
|
|
||||||
#[error("The directory does not exist")]
|
|
||||||
NotFound,
|
|
||||||
#[error("The directory is not empty")]
|
|
||||||
NotEmpty,
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum DeleteFileError {
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct CreateDirectoryRequest {
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CreateDirectoryRequest {
|
|
||||||
pub fn new(path: AbsoluteFilePath) -> Self {
|
|
||||||
Self { path }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum CreateDirectoryError {
|
|
||||||
#[error("The directory already exists")]
|
|
||||||
Exists,
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct CreateFileRequest {
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
data: Box<[u8]>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CreateFileRequest {
|
|
||||||
pub fn new(path: AbsoluteFilePath, data: Box<[u8]>) -> Self {
|
|
||||||
Self { path, data }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn data(&self) -> &[u8] {
|
|
||||||
&self.data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum CreateFileError {
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct RenameEntryRequest {
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
new_name: FileName,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RenameEntryRequest {
|
|
||||||
pub fn new(path: AbsoluteFilePath, new_name: FileName) -> Self {
|
|
||||||
Self { path, new_name }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_name(&self) -> &FileName {
|
|
||||||
&self.new_name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum RenameEntryError {
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct FetchFileRequest {
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FetchFileRequest {
|
|
||||||
pub fn new(path: AbsoluteFilePath) -> Self {
|
|
||||||
Self { path }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum FetchFileError {
|
|
||||||
#[error("The file does not exist")]
|
|
||||||
NotFound,
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
30
backend/src/lib/domain/warren/models/file/requests/cat.rs
Normal file
30
backend/src/lib/domain/warren/models/file/requests/cat.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::file::AbsoluteFilePath;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct CatRequest {
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CatRequest {
|
||||||
|
pub fn new(path: AbsoluteFilePath) -> Self {
|
||||||
|
Self { path }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_path(self) -> AbsoluteFilePath {
|
||||||
|
self.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum CatError {
|
||||||
|
#[error("The file does not exist")]
|
||||||
|
NotFound,
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
30
backend/src/lib/domain/warren/models/file/requests/ls.rs
Normal file
30
backend/src/lib/domain/warren/models/file/requests/ls.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::file::AbsoluteFilePath;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct LsRequest {
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LsRequest {
|
||||||
|
pub fn new(path: AbsoluteFilePath) -> Self {
|
||||||
|
Self { path }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_path(self) -> AbsoluteFilePath {
|
||||||
|
self.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum LsError {
|
||||||
|
#[error("File at path {0} does not exist")]
|
||||||
|
NotFound(String),
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
30
backend/src/lib/domain/warren/models/file/requests/mkdir.rs
Normal file
30
backend/src/lib/domain/warren/models/file/requests/mkdir.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::file::AbsoluteFilePath;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct MkdirRequest {
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MkdirRequest {
|
||||||
|
pub fn new(path: AbsoluteFilePath) -> Self {
|
||||||
|
Self { path }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_path(self) -> AbsoluteFilePath {
|
||||||
|
self.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum MkdirError {
|
||||||
|
#[error("The directory already exists")]
|
||||||
|
Exists,
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
15
backend/src/lib/domain/warren/models/file/requests/mod.rs
Normal file
15
backend/src/lib/domain/warren/models/file/requests/mod.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
mod cat;
|
||||||
|
mod ls;
|
||||||
|
mod mkdir;
|
||||||
|
mod mv;
|
||||||
|
mod rm;
|
||||||
|
mod save;
|
||||||
|
mod touch;
|
||||||
|
|
||||||
|
pub use cat::*;
|
||||||
|
pub use ls::*;
|
||||||
|
pub use mkdir::*;
|
||||||
|
pub use mv::*;
|
||||||
|
pub use rm::*;
|
||||||
|
pub use save::*;
|
||||||
|
pub use touch::*;
|
||||||
37
backend/src/lib/domain/warren/models/file/requests/mv.rs
Normal file
37
backend/src/lib/domain/warren/models/file/requests/mv.rs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::file::AbsoluteFilePath;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct MvRequest {
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
target_path: AbsoluteFilePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MvRequest {
|
||||||
|
pub fn new(path: AbsoluteFilePath, target_path: AbsoluteFilePath) -> Self {
|
||||||
|
Self { path, target_path }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn target_path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.target_path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(self) -> (AbsoluteFilePath, AbsoluteFilePath) {
|
||||||
|
(self.path, self.target_path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum MvError {
|
||||||
|
#[error("The path does not exist")]
|
||||||
|
NotFound,
|
||||||
|
#[error("The target path already exists")]
|
||||||
|
AlreadyExists,
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
37
backend/src/lib/domain/warren/models/file/requests/rm.rs
Normal file
37
backend/src/lib/domain/warren/models/file/requests/rm.rs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::file::AbsoluteFilePath;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct RmRequest {
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
force: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RmRequest {
|
||||||
|
pub fn new(path: AbsoluteFilePath, force: bool) -> Self {
|
||||||
|
Self { path, force }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_path(self) -> AbsoluteFilePath {
|
||||||
|
self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn force(&self) -> bool {
|
||||||
|
self.force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum RmError {
|
||||||
|
#[error("The path does not exist")]
|
||||||
|
NotFound,
|
||||||
|
#[error("The directory is not empty")]
|
||||||
|
NotEmpty,
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
53
backend/src/lib/domain/warren/models/file/requests/save.rs
Normal file
53
backend/src/lib/domain/warren/models/file/requests/save.rs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::{file::AbsoluteFilePath, warren::UploadFileStream};
|
||||||
|
|
||||||
|
pub struct SaveRequest<'s> {
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
stream: UploadFileStream<'s>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'s> SaveRequest<'s> {
|
||||||
|
pub fn new(path: AbsoluteFilePath, stream: UploadFileStream<'s>) -> Self {
|
||||||
|
Self { path, stream }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stream(&self) -> &'s UploadFileStream {
|
||||||
|
&self.stream
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stream_mut(&mut self) -> &'s mut UploadFileStream {
|
||||||
|
&mut self.stream
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(self) -> (AbsoluteFilePath, UploadFileStream<'s>) {
|
||||||
|
(self.path, self.stream)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum SaveError {
|
||||||
|
#[error("The path does not exist")]
|
||||||
|
NotFound,
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct SaveResponse {
|
||||||
|
files: Vec<AbsoluteFilePath>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SaveResponse {
|
||||||
|
pub fn new(files: Vec<AbsoluteFilePath>) -> Self {
|
||||||
|
Self { files }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn files(&self) -> &Vec<AbsoluteFilePath> {
|
||||||
|
&self.files
|
||||||
|
}
|
||||||
|
}
|
||||||
30
backend/src/lib/domain/warren/models/file/requests/touch.rs
Normal file
30
backend/src/lib/domain/warren/models/file/requests/touch.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::file::AbsoluteFilePath;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct TouchRequest {
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TouchRequest {
|
||||||
|
pub fn new(path: AbsoluteFilePath) -> Self {
|
||||||
|
Self { path }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_path(self) -> AbsoluteFilePath {
|
||||||
|
self.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum TouchError {
|
||||||
|
#[error("The path does not exist")]
|
||||||
|
NotFound,
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
|
use bytes::Bytes;
|
||||||
|
use futures_util::Stream;
|
||||||
|
use futures_util::StreamExt;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::domain::warren::models::file::SaveResponse;
|
||||||
use crate::domain::warren::models::file::{
|
use crate::domain::warren::models::file::{
|
||||||
AbsoluteFilePath, CreateDirectoryError, CreateDirectoryRequest, CreateFileError,
|
AbsoluteFilePath, CatError, CatRequest, File, FileName, LsError, LsRequest, MkdirError,
|
||||||
CreateFileRequest, DeleteDirectoryError, DeleteDirectoryRequest, DeleteFileError,
|
MkdirRequest, MvError, MvRequest, RmError, RmRequest, SaveError, SaveRequest, TouchError,
|
||||||
DeleteFileRequest, FetchFileError, FetchFileRequest, File, FileName, FilePath, ListFilesError,
|
TouchRequest,
|
||||||
ListFilesRequest, RelativeFilePath, RenameEntryError, RenameEntryRequest,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Warren, WarrenName};
|
use super::{Warren, WarrenName};
|
||||||
@@ -55,60 +58,73 @@ pub enum FetchWarrensError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ListWarrenFilesRequest {
|
pub struct WarrenLsRequest {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: AbsoluteFilePath,
|
base: LsRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListWarrenFilesRequest {
|
impl WarrenLsRequest {
|
||||||
pub fn new(warren_id: Uuid, path: AbsoluteFilePath) -> Self {
|
pub fn new(warren_id: Uuid, base: LsRequest) -> Self {
|
||||||
Self { warren_id, path }
|
Self { warren_id, base }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren_id(&self) -> &Uuid {
|
pub fn warren_id(&self) -> &Uuid {
|
||||||
&self.warren_id
|
&self.warren_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
pub fn base(&self) -> &LsRequest {
|
||||||
&self.path
|
&self.base
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_fs_request(self, warren: &Warren) -> ListFilesRequest {
|
pub fn build_fs_request(self, warren: &Warren) -> LsRequest {
|
||||||
let path = warren.path().clone().join(&self.path.to_relative());
|
let path = warren
|
||||||
ListFilesRequest::new(path)
|
.path()
|
||||||
|
.clone()
|
||||||
|
.join(&self.base.into_path().to_relative());
|
||||||
|
|
||||||
|
LsRequest::new(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FetchWarrenRequest> for ListWarrenFilesRequest {
|
impl Into<FetchWarrenRequest> for WarrenLsRequest {
|
||||||
fn into(self) -> FetchWarrenRequest {
|
fn into(self) -> FetchWarrenRequest {
|
||||||
FetchWarrenRequest::new(self.warren_id)
|
FetchWarrenRequest::new(self.warren_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ListWarrenFilesResponse {
|
pub struct WarrenLsResponse {
|
||||||
warren: Warren,
|
warren: Warren,
|
||||||
|
path: AbsoluteFilePath,
|
||||||
files: Vec<File>,
|
files: Vec<File>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListWarrenFilesResponse {
|
impl WarrenLsResponse {
|
||||||
pub fn new(warren: Warren, files: Vec<File>) -> Self {
|
pub fn new(warren: Warren, path: AbsoluteFilePath, files: Vec<File>) -> Self {
|
||||||
Self { warren, files }
|
Self {
|
||||||
|
warren,
|
||||||
|
path,
|
||||||
|
files,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren(&self) -> &Warren {
|
pub fn warren(&self) -> &Warren {
|
||||||
&self.warren
|
&self.warren
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
pub fn files(&self) -> &Vec<File> {
|
pub fn files(&self) -> &Vec<File> {
|
||||||
&self.files
|
&self.files
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ListWarrenFilesError {
|
pub enum WarrenLsError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FileSystem(#[from] ListFilesError),
|
FileSystem(#[from] LsError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FetchWarren(#[from] FetchWarrenError),
|
FetchWarren(#[from] FetchWarrenError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
@@ -116,44 +132,48 @@ pub enum ListWarrenFilesError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct CreateWarrenDirectoryRequest {
|
pub struct WarrenMkdirRequest {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: AbsoluteFilePath,
|
base: MkdirRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateWarrenDirectoryRequest {
|
impl WarrenMkdirRequest {
|
||||||
pub fn new(warren_id: Uuid, path: AbsoluteFilePath) -> Self {
|
pub fn new(warren_id: Uuid, base: MkdirRequest) -> Self {
|
||||||
Self { warren_id, path }
|
Self { warren_id, base }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren_id(&self) -> &Uuid {
|
pub fn warren_id(&self) -> &Uuid {
|
||||||
&self.warren_id
|
&self.warren_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
pub fn base(&self) -> &MkdirRequest {
|
||||||
&self.path
|
&self.base
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_fs_request(self, warren: &Warren) -> CreateDirectoryRequest {
|
pub fn build_fs_request(self, warren: &Warren) -> MkdirRequest {
|
||||||
let path = warren.path().clone().join(&self.path.to_relative());
|
let path = warren
|
||||||
CreateDirectoryRequest::new(path)
|
.path()
|
||||||
|
.clone()
|
||||||
|
.join(&self.base.into_path().to_relative());
|
||||||
|
|
||||||
|
MkdirRequest::new(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FetchWarrenRequest> for CreateWarrenDirectoryRequest {
|
impl Into<FetchWarrenRequest> for WarrenMkdirRequest {
|
||||||
fn into(self) -> FetchWarrenRequest {
|
fn into(self) -> FetchWarrenRequest {
|
||||||
FetchWarrenRequest::new(self.warren_id)
|
FetchWarrenRequest::new(self.warren_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct CreateWarrenDirectoryResponse {
|
pub struct WarrenMkdirResponse {
|
||||||
warren: Warren,
|
warren: Warren,
|
||||||
path: FilePath,
|
path: AbsoluteFilePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateWarrenDirectoryResponse {
|
impl WarrenMkdirResponse {
|
||||||
pub fn new(warren: Warren, path: FilePath) -> Self {
|
pub fn new(warren: Warren, path: AbsoluteFilePath) -> Self {
|
||||||
Self { warren, path }
|
Self { warren, path }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,15 +181,15 @@ impl CreateWarrenDirectoryResponse {
|
|||||||
&self.warren
|
&self.warren
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &FilePath {
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
&self.path
|
&self.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum CreateWarrenDirectoryError {
|
pub enum WarrenMkdirError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FileSystem(#[from] CreateDirectoryError),
|
FileSystem(#[from] MkdirError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FetchWarren(#[from] FetchWarrenError),
|
FetchWarren(#[from] FetchWarrenError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
@@ -177,53 +197,49 @@ pub enum CreateWarrenDirectoryError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct DeleteWarrenDirectoryRequest {
|
pub struct WarrenRmRequest {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: AbsoluteFilePath,
|
base: RmRequest,
|
||||||
force: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeleteWarrenDirectoryRequest {
|
impl WarrenRmRequest {
|
||||||
pub fn new(warren_id: Uuid, path: AbsoluteFilePath, force: bool) -> Self {
|
pub fn new(warren_id: Uuid, base: RmRequest) -> Self {
|
||||||
Self {
|
Self { warren_id, base }
|
||||||
warren_id,
|
|
||||||
path,
|
|
||||||
force,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_fs_request(self, warren: &Warren) -> DeleteDirectoryRequest {
|
|
||||||
let path = warren.path().clone().join(&self.path.to_relative());
|
|
||||||
DeleteDirectoryRequest::new(path, self.force)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren_id(&self) -> &Uuid {
|
pub fn warren_id(&self) -> &Uuid {
|
||||||
&self.warren_id
|
&self.warren_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
pub fn base(&self) -> &RmRequest {
|
||||||
&self.path
|
&self.base
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn force(&self) -> bool {
|
pub fn build_fs_request(self, warren: &Warren) -> RmRequest {
|
||||||
self.force
|
let force = self.base.force();
|
||||||
|
let path = warren
|
||||||
|
.path()
|
||||||
|
.clone()
|
||||||
|
.join(&self.base.into_path().to_relative());
|
||||||
|
|
||||||
|
RmRequest::new(path, force)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FetchWarrenRequest> for &DeleteWarrenDirectoryRequest {
|
impl Into<FetchWarrenRequest> for &WarrenRmRequest {
|
||||||
fn into(self) -> FetchWarrenRequest {
|
fn into(self) -> FetchWarrenRequest {
|
||||||
FetchWarrenRequest::new(self.warren_id)
|
FetchWarrenRequest::new(self.warren_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct DeleteWarrenDirectoryResponse {
|
pub struct WarrenRmResponse {
|
||||||
warren: Warren,
|
warren: Warren,
|
||||||
path: FilePath,
|
path: AbsoluteFilePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeleteWarrenDirectoryResponse {
|
impl WarrenRmResponse {
|
||||||
pub fn new(warren: Warren, path: FilePath) -> Self {
|
pub fn new(warren: Warren, path: AbsoluteFilePath) -> Self {
|
||||||
Self { warren, path }
|
Self { warren, path }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,248 +247,197 @@ impl DeleteWarrenDirectoryResponse {
|
|||||||
&self.warren
|
&self.warren
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &FilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum DeleteWarrenDirectoryError {
|
|
||||||
#[error(transparent)]
|
|
||||||
FileSystem(#[from] DeleteDirectoryError),
|
|
||||||
#[error(transparent)]
|
|
||||||
FetchWarren(#[from] FetchWarrenError),
|
|
||||||
#[error(transparent)]
|
|
||||||
Unknown(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct DeleteWarrenFileRequest {
|
|
||||||
warren_id: Uuid,
|
|
||||||
path: AbsoluteFilePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DeleteWarrenFileRequest {
|
|
||||||
pub fn new(warren_id: Uuid, path: AbsoluteFilePath) -> Self {
|
|
||||||
Self { warren_id, path }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_fs_request(self, warren: &Warren) -> DeleteFileRequest {
|
|
||||||
let path = warren.path().clone().join(&self.path.to_relative());
|
|
||||||
DeleteFileRequest::new(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn warren_id(&self) -> &Uuid {
|
|
||||||
&self.warren_id
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
&self.path
|
&self.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FetchWarrenRequest> for &DeleteWarrenFileRequest {
|
|
||||||
fn into(self) -> FetchWarrenRequest {
|
|
||||||
FetchWarrenRequest::new(self.warren_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct DeleteWarrenFileResponse {
|
|
||||||
warren: Warren,
|
|
||||||
path: FilePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DeleteWarrenFileResponse {
|
|
||||||
pub fn new(warren: Warren, path: FilePath) -> Self {
|
|
||||||
Self { warren, path }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn warren(&self) -> &Warren {
|
|
||||||
&self.warren
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &FilePath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum DeleteWarrenFileError {
|
pub enum WarrenRmError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FileSystem(#[from] DeleteFileError),
|
FileSystem(#[from] RmError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FetchWarren(#[from] FetchWarrenError),
|
FetchWarren(#[from] FetchWarrenError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Unknown(#[from] anyhow::Error),
|
Unknown(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
pub struct WarrenSaveRequest<'s> {
|
||||||
pub struct UploadWarrenFilesRequest {
|
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: AbsoluteFilePath,
|
base: SaveRequest<'s>,
|
||||||
files: UploadFileList,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UploadWarrenFilesRequest {
|
impl<'s> WarrenSaveRequest<'s> {
|
||||||
pub fn new(warren_id: Uuid, path: AbsoluteFilePath, files: UploadFileList) -> Self {
|
pub fn new(warren_id: Uuid, base: SaveRequest<'s>) -> Self {
|
||||||
Self {
|
Self { warren_id, base }
|
||||||
warren_id,
|
|
||||||
path,
|
|
||||||
files,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren_id(&self) -> &Uuid {
|
pub fn warren_id(&self) -> &Uuid {
|
||||||
&self.warren_id
|
&self.warren_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_fs_requests(self, warren: &Warren) -> Vec<CreateFileRequest> {
|
pub fn base(&self) -> &SaveRequest<'s> {
|
||||||
let base_upload_path = self.path.as_relative();
|
&self.base
|
||||||
|
}
|
||||||
|
|
||||||
self.files
|
pub fn base_mut(&mut self) -> &mut SaveRequest<'s> {
|
||||||
.0
|
&mut self.base
|
||||||
.into_iter()
|
}
|
||||||
.map(|f| {
|
|
||||||
let file_name = FilePath::new(&f.file_name.to_string()).unwrap();
|
pub fn build_fs_request(self, warren: &Warren) -> SaveRequest<'s> {
|
||||||
let relative_file_path: RelativeFilePath = file_name.try_into().unwrap();
|
let (base_path, stream) = self.base.unpack();
|
||||||
let absolute_file_path = warren
|
let path = warren.path().clone().join(&base_path.to_relative());
|
||||||
.path()
|
|
||||||
.clone()
|
SaveRequest::new(path, stream)
|
||||||
.join(&base_upload_path)
|
|
||||||
.join(&relative_file_path);
|
|
||||||
CreateFileRequest::new(absolute_file_path, f.data)
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FetchWarrenRequest> for &UploadWarrenFilesRequest {
|
impl Into<FetchWarrenRequest> for &WarrenSaveRequest<'_> {
|
||||||
fn into(self) -> FetchWarrenRequest {
|
fn into(self) -> FetchWarrenRequest {
|
||||||
FetchWarrenRequest::new(self.warren_id)
|
FetchWarrenRequest::new(self.warren_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct UploadWarrenFilesResponse {
|
pub struct WarrenSaveResponse {
|
||||||
warren: Warren,
|
warren: Warren,
|
||||||
paths: Vec<FilePath>,
|
path: AbsoluteFilePath,
|
||||||
|
base: SaveResponse,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UploadWarrenFilesResponse {
|
impl WarrenSaveResponse {
|
||||||
pub fn new(warren: Warren, paths: Vec<FilePath>) -> Self {
|
pub fn new(warren: Warren, path: AbsoluteFilePath, base: SaveResponse) -> Self {
|
||||||
Self { warren, paths }
|
Self { warren, path, base }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren(&self) -> &Warren {
|
pub fn warren(&self) -> &Warren {
|
||||||
&self.warren
|
&self.warren
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn paths(&self) -> &Vec<FilePath> {
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
&self.paths
|
&self.path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn base(&self) -> &SaveResponse {
|
||||||
|
&self.base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum UploadWarrenFilesError {
|
pub enum WarrenSaveError {
|
||||||
#[error("Failed to upload the file at index {fail_index}")]
|
|
||||||
Partial { fail_index: usize },
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FileSystem(#[from] CreateFileError),
|
FileSystem(#[from] SaveError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FetchWarren(#[from] FetchWarrenError),
|
FetchWarren(#[from] FetchWarrenError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Unknown(#[from] anyhow::Error),
|
Unknown(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
pub struct UploadFileStream<'i>(
|
||||||
pub struct UploadFileList(Vec<UploadFile>);
|
Box<dyn Stream<Item = Result<UploadFile<'i>, anyhow::Error>> + Unpin + Send + 'i>,
|
||||||
|
);
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
impl<'i> UploadFileStream<'i> {
|
||||||
pub enum UploadFileListError {
|
pub fn new<S>(stream: S) -> Self
|
||||||
#[error("The file list must not be empty")]
|
where
|
||||||
Empty,
|
S: Stream<Item = Result<UploadFile<'i>, anyhow::Error>> + Unpin + Send + 'i,
|
||||||
}
|
{
|
||||||
|
Self(Box::new(stream))
|
||||||
impl UploadFileList {
|
|
||||||
pub fn new(files: Vec<UploadFile>) -> Result<Self, UploadFileListError> {
|
|
||||||
if files.len() < 1 {
|
|
||||||
return Err(UploadFileListError::Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self(files))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
impl<'i> Stream for UploadFileStream<'i> {
|
||||||
pub struct UploadFile {
|
type Item = Result<UploadFile<'i>, anyhow::Error>;
|
||||||
|
|
||||||
|
fn poll_next(
|
||||||
|
self: std::pin::Pin<&mut Self>,
|
||||||
|
cx: &mut std::task::Context<'_>,
|
||||||
|
) -> std::task::Poll<Option<Self::Item>> {
|
||||||
|
self.get_mut().0.poll_next_unpin(cx)
|
||||||
|
}
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.0.size_hint()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct UploadFile<'a> {
|
||||||
file_name: FileName,
|
file_name: FileName,
|
||||||
data: Box<[u8]>,
|
stream: Box<dyn Stream<Item = Result<Bytes, tokio::io::Error>> + Unpin + Send + 'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UploadFile {
|
impl<'a> UploadFile<'a> {
|
||||||
pub fn new(file_name: FileName, data: Box<[u8]>) -> Self {
|
pub fn new<S>(file_name: FileName, stream: S) -> Self
|
||||||
Self { file_name, data }
|
where
|
||||||
|
S: Stream<Item = Result<Bytes, tokio::io::Error>> + Unpin + Send + 'a,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
file_name,
|
||||||
|
stream: Box::new(stream),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_name(&self) -> &FileName {
|
pub fn file_name(&self) -> &FileName {
|
||||||
&self.file_name
|
&self.file_name
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn data(&self) -> &[u8] {
|
impl<'a> Stream for UploadFile<'a> {
|
||||||
&self.data
|
type Item = Result<Bytes, tokio::io::Error>;
|
||||||
|
|
||||||
|
fn poll_next(
|
||||||
|
self: std::pin::Pin<&mut Self>,
|
||||||
|
cx: &mut std::task::Context<'_>,
|
||||||
|
) -> std::task::Poll<Option<Self::Item>> {
|
||||||
|
self.get_mut().stream.poll_next_unpin(cx)
|
||||||
|
}
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.stream.size_hint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct RenameWarrenEntryRequest {
|
pub struct WarrenMvRequest {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: AbsoluteFilePath,
|
base: MvRequest,
|
||||||
new_name: FileName,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenameWarrenEntryRequest {
|
impl WarrenMvRequest {
|
||||||
pub fn new(warren_id: Uuid, path: AbsoluteFilePath, new_name: FileName) -> Self {
|
pub fn new(warren_id: Uuid, base: MvRequest) -> Self {
|
||||||
Self {
|
Self { warren_id, base }
|
||||||
warren_id,
|
|
||||||
path,
|
|
||||||
new_name,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren_id(&self) -> &Uuid {
|
pub fn warren_id(&self) -> &Uuid {
|
||||||
&self.warren_id
|
&self.warren_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
pub fn base(&self) -> &MvRequest {
|
||||||
&self.path
|
&self.base
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_name(&self) -> &FileName {
|
pub fn build_fs_request(self, warren: &Warren) -> MvRequest {
|
||||||
&self.new_name
|
let (base_path, base_target_path) = self.base.unpack();
|
||||||
}
|
let path = warren.path().clone().join(&base_path.to_relative());
|
||||||
|
let target_path = warren.path().clone().join(&base_target_path.to_relative());
|
||||||
|
|
||||||
pub fn to_fs_request(self, warren: &Warren) -> RenameEntryRequest {
|
MvRequest::new(path, target_path)
|
||||||
let path = warren.path().clone().join(&self.path.to_relative());
|
|
||||||
RenameEntryRequest::new(path, self.new_name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FetchWarrenRequest> for &RenameWarrenEntryRequest {
|
impl Into<FetchWarrenRequest> for &WarrenMvRequest {
|
||||||
fn into(self) -> FetchWarrenRequest {
|
fn into(self) -> FetchWarrenRequest {
|
||||||
FetchWarrenRequest::new(self.warren_id)
|
FetchWarrenRequest::new(self.warren_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct RenameWarrenEntryResponse {
|
pub struct WarrenMvResponse {
|
||||||
warren: Warren,
|
warren: Warren,
|
||||||
old_path: AbsoluteFilePath,
|
old_path: AbsoluteFilePath,
|
||||||
path: FilePath,
|
path: AbsoluteFilePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenameWarrenEntryResponse {
|
impl WarrenMvResponse {
|
||||||
pub fn new(warren: Warren, old_path: AbsoluteFilePath, path: FilePath) -> Self {
|
pub fn new(warren: Warren, old_path: AbsoluteFilePath, path: AbsoluteFilePath) -> Self {
|
||||||
Self {
|
Self {
|
||||||
warren,
|
warren,
|
||||||
old_path,
|
old_path,
|
||||||
@@ -488,17 +453,17 @@ impl RenameWarrenEntryResponse {
|
|||||||
&self.old_path
|
&self.old_path
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &FilePath {
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
&self.path
|
&self.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum RenameWarrenEntryError {
|
pub enum WarrenMvError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FetchWarren(#[from] FetchWarrenError),
|
FetchWarren(#[from] FetchWarrenError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Rename(#[from] RenameEntryError),
|
FileSystem(#[from] MvError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Unknown(#[from] anyhow::Error),
|
Unknown(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
@@ -603,42 +568,111 @@ pub enum DeleteWarrenError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct FetchWarrenFileRequest {
|
pub struct WarrenCatRequest {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: AbsoluteFilePath,
|
base: CatRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FetchWarrenFileRequest {
|
impl WarrenCatRequest {
|
||||||
pub fn new(warren_id: Uuid, path: AbsoluteFilePath) -> Self {
|
pub fn new(warren_id: Uuid, base: CatRequest) -> Self {
|
||||||
Self { warren_id, path }
|
Self { warren_id, base }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warren_id(&self) -> &Uuid {
|
pub fn warren_id(&self) -> &Uuid {
|
||||||
&self.warren_id
|
&self.warren_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &AbsoluteFilePath {
|
pub fn base(&self) -> &CatRequest {
|
||||||
&self.path
|
&self.base
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_fs_request(self, warren: &Warren) -> FetchFileRequest {
|
pub fn build_fs_request(self, warren: &Warren) -> CatRequest {
|
||||||
let path = warren.path().clone().join(&self.path.to_relative());
|
let path = warren
|
||||||
FetchFileRequest::new(path)
|
.path()
|
||||||
|
.clone()
|
||||||
|
.join(&self.base.into_path().to_relative());
|
||||||
|
|
||||||
|
CatRequest::new(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FetchWarrenRequest> for &FetchWarrenFileRequest {
|
impl Into<FetchWarrenRequest> for &WarrenCatRequest {
|
||||||
fn into(self) -> FetchWarrenRequest {
|
fn into(self) -> FetchWarrenRequest {
|
||||||
FetchWarrenRequest::new(self.warren_id)
|
FetchWarrenRequest::new(self.warren_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum FetchWarrenFileError {
|
pub enum WarrenCatError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FetchWarren(#[from] FetchWarrenError),
|
FetchWarren(#[from] FetchWarrenError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Fs(#[from] FetchFileError),
|
FileSystem(#[from] CatError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Unknown(#[from] anyhow::Error),
|
Unknown(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct WarrenTouchRequest {
|
||||||
|
warren_id: Uuid,
|
||||||
|
base: TouchRequest,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WarrenTouchRequest {
|
||||||
|
pub fn new(warren_id: Uuid, base: TouchRequest) -> Self {
|
||||||
|
Self { warren_id, base }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn warren_id(&self) -> &Uuid {
|
||||||
|
&self.warren_id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn base(&self) -> &TouchRequest {
|
||||||
|
&self.base
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build_fs_request(self, warren: &Warren) -> TouchRequest {
|
||||||
|
let path = warren
|
||||||
|
.path()
|
||||||
|
.clone()
|
||||||
|
.join(&self.base.into_path().to_relative());
|
||||||
|
|
||||||
|
TouchRequest::new(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<FetchWarrenRequest> for &WarrenTouchRequest {
|
||||||
|
fn into(self) -> FetchWarrenRequest {
|
||||||
|
FetchWarrenRequest::new(self.warren_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum WarrenTouchError {
|
||||||
|
#[error(transparent)]
|
||||||
|
FetchWarren(#[from] FetchWarrenError),
|
||||||
|
#[error(transparent)]
|
||||||
|
FileSystem(#[from] TouchError),
|
||||||
|
#[error(transparent)]
|
||||||
|
Unknown(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct WarrenTouchResponse {
|
||||||
|
warren: Warren,
|
||||||
|
path: AbsoluteFilePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WarrenTouchResponse {
|
||||||
|
pub fn new(warren: Warren, path: AbsoluteFilePath) -> Self {
|
||||||
|
Self { warren, path }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn warren(&self) -> &Warren {
|
||||||
|
&self.warren
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &AbsoluteFilePath {
|
||||||
|
&self.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,55 +17,51 @@ pub trait WarrenMetrics: Clone + Send + Sync + 'static {
|
|||||||
fn record_warren_list_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_list_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_warren_list_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_list_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_list_warren_files_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_ls_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_list_warren_files_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_ls_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_warren_fetch_file_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_cat_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_warren_fetch_file_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_cat_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_warren_directory_creation_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_mkdir_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_warren_directory_creation_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_mkdir_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_warren_directory_deletion_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_rm_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_warren_directory_deletion_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_rm_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
|
fn record_warren_mv_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
fn record_warren_mv_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
/// A single file upload succeeded
|
/// A single file upload succeeded
|
||||||
fn record_warren_file_upload_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_save_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
/// A single file upload failed
|
/// A single file upload failed
|
||||||
fn record_warren_file_upload_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_save_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
/// An upload succeeded fully
|
fn record_warren_touch_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_warren_files_upload_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_warren_touch_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
/// An upload failed at least partially
|
|
||||||
fn record_warren_files_upload_failure(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn record_warren_file_deletion_success(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
fn record_warren_file_deletion_failure(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn record_warren_entry_rename_success(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
fn record_warren_entry_rename_failure(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FileSystemMetrics: Clone + Send + Sync + 'static {
|
pub trait FileSystemMetrics: Clone + Send + Sync + 'static {
|
||||||
fn record_list_files_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_ls_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_list_files_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_ls_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_directory_creation_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_cat_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_directory_creation_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_cat_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_directory_deletion_success(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
fn record_directory_deletion_failure(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn record_file_creation_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_mkdir_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_file_creation_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_mkdir_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_file_fetch_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_rm_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_file_fetch_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_rm_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_file_deletion_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_mv_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_file_deletion_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_mv_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_entry_rename_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_save_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_entry_rename_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_save_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
|
fn record_touch_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
fn record_touch_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AuthMetrics: Clone + Send + Sync + 'static {
|
pub trait AuthMetrics: Clone + Send + Sync + 'static {
|
||||||
@@ -123,26 +119,24 @@ pub trait AuthMetrics: Clone + Send + Sync + 'static {
|
|||||||
fn record_auth_warren_fetch_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_fetch_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_fetch_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_fetch_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_auth_warren_file_list_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_ls_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_file_list_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_ls_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_auth_warren_directory_creation_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_cat_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_directory_creation_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_cat_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_auth_warren_directory_deletion_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_mkdir_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_directory_deletion_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_mkdir_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_auth_warren_fetch_file_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_rm_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_fetch_file_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_rm_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
/// An upload succeeded fully
|
fn record_auth_warren_mv_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_files_upload_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_mv_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
/// An upload failed at least partially
|
|
||||||
fn record_auth_warren_files_upload_failure(&self) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn record_auth_warren_file_deletion_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_save_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_file_deletion_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_save_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn record_auth_warren_entry_rename_success(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_touch_success(&self) -> impl Future<Output = ()> + Send;
|
||||||
fn record_auth_warren_entry_rename_failure(&self) -> impl Future<Output = ()> + Send;
|
fn record_auth_warren_touch_failure(&self) -> impl Future<Output = ()> + Send;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ use super::models::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
file::{
|
file::{
|
||||||
CreateDirectoryError, CreateDirectoryRequest, CreateFileError, CreateFileRequest,
|
CatError, CatRequest, File, FileStream, LsError, LsRequest, MkdirError, MkdirRequest,
|
||||||
DeleteDirectoryError, DeleteDirectoryRequest, DeleteFileError, DeleteFileRequest,
|
MvError, MvRequest, RmError, RmRequest, SaveError, SaveRequest, SaveResponse, TouchError,
|
||||||
FetchFileError, FetchFileRequest, File, FilePath, FileStream, ListFilesError,
|
TouchRequest,
|
||||||
ListFilesRequest, RenameEntryError, RenameEntryRequest,
|
|
||||||
},
|
},
|
||||||
user::{
|
user::{
|
||||||
CreateUserError, CreateUserRequest, DeleteUserError, DeleteUserRequest, EditUserError,
|
CreateUserError, CreateUserRequest, DeleteUserError, DeleteUserRequest, EditUserError,
|
||||||
@@ -35,16 +34,14 @@ use super::models::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
warren::{
|
warren::{
|
||||||
CreateWarrenDirectoryError, CreateWarrenDirectoryRequest, CreateWarrenDirectoryResponse,
|
CreateWarrenError, CreateWarrenRequest, DeleteWarrenError, DeleteWarrenRequest,
|
||||||
CreateWarrenError, CreateWarrenRequest, DeleteWarrenDirectoryError,
|
EditWarrenError, EditWarrenRequest, FetchWarrenError, FetchWarrenRequest,
|
||||||
DeleteWarrenDirectoryRequest, DeleteWarrenDirectoryResponse, DeleteWarrenError,
|
FetchWarrensError, FetchWarrensRequest, ListWarrensError, ListWarrensRequest, Warren,
|
||||||
DeleteWarrenFileError, DeleteWarrenFileRequest, DeleteWarrenFileResponse,
|
WarrenCatError, WarrenCatRequest, WarrenLsError, WarrenLsRequest, WarrenLsResponse,
|
||||||
DeleteWarrenRequest, EditWarrenError, EditWarrenRequest, FetchWarrenError,
|
WarrenMkdirError, WarrenMkdirRequest, WarrenMkdirResponse, WarrenMvError, WarrenMvRequest,
|
||||||
FetchWarrenFileError, FetchWarrenFileRequest, FetchWarrenRequest, FetchWarrensError,
|
WarrenMvResponse, WarrenRmError, WarrenRmRequest, WarrenRmResponse, WarrenSaveError,
|
||||||
FetchWarrensRequest, ListWarrenFilesError, ListWarrenFilesRequest, ListWarrenFilesResponse,
|
WarrenSaveRequest, WarrenSaveResponse, WarrenTouchError, WarrenTouchRequest,
|
||||||
ListWarrensError, ListWarrensRequest, RenameWarrenEntryError, RenameWarrenEntryRequest,
|
WarrenTouchResponse,
|
||||||
RenameWarrenEntryResponse, UploadWarrenFilesError, UploadWarrenFilesRequest,
|
|
||||||
UploadWarrenFilesResponse, Warren,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,73 +72,48 @@ pub trait WarrenService: Clone + Send + Sync + 'static {
|
|||||||
request: FetchWarrenRequest,
|
request: FetchWarrenRequest,
|
||||||
) -> impl Future<Output = Result<Warren, FetchWarrenError>> + Send;
|
) -> impl Future<Output = Result<Warren, FetchWarrenError>> + Send;
|
||||||
|
|
||||||
fn fetch_warren_file(
|
fn warren_ls(
|
||||||
&self,
|
&self,
|
||||||
request: FetchWarrenFileRequest,
|
request: WarrenLsRequest,
|
||||||
) -> impl Future<Output = Result<FileStream, FetchWarrenFileError>> + Send;
|
) -> impl Future<Output = Result<WarrenLsResponse, WarrenLsError>> + Send;
|
||||||
|
fn warren_cat(
|
||||||
fn list_warren_files(
|
|
||||||
&self,
|
&self,
|
||||||
request: ListWarrenFilesRequest,
|
request: WarrenCatRequest,
|
||||||
) -> impl Future<Output = Result<ListWarrenFilesResponse, ListWarrenFilesError>> + Send;
|
) -> impl Future<Output = Result<FileStream, WarrenCatError>> + Send;
|
||||||
|
fn warren_mkdir(
|
||||||
fn create_warren_directory(
|
|
||||||
&self,
|
&self,
|
||||||
request: CreateWarrenDirectoryRequest,
|
request: WarrenMkdirRequest,
|
||||||
) -> impl Future<Output = Result<CreateWarrenDirectoryResponse, CreateWarrenDirectoryError>> + Send;
|
) -> impl Future<Output = Result<WarrenMkdirResponse, WarrenMkdirError>> + Send;
|
||||||
|
fn warren_rm(
|
||||||
fn delete_warren_directory(
|
|
||||||
&self,
|
&self,
|
||||||
request: DeleteWarrenDirectoryRequest,
|
request: WarrenRmRequest,
|
||||||
) -> impl Future<Output = Result<DeleteWarrenDirectoryResponse, DeleteWarrenDirectoryError>> + Send;
|
) -> impl Future<Output = Result<WarrenRmResponse, WarrenRmError>> + Send;
|
||||||
|
fn warren_mv(
|
||||||
fn upload_warren_files(
|
|
||||||
&self,
|
&self,
|
||||||
request: UploadWarrenFilesRequest,
|
request: WarrenMvRequest,
|
||||||
) -> impl Future<Output = Result<UploadWarrenFilesResponse, UploadWarrenFilesError>> + Send;
|
) -> impl Future<Output = Result<WarrenMvResponse, WarrenMvError>> + Send;
|
||||||
fn delete_warren_file(
|
fn warren_save(
|
||||||
&self,
|
&self,
|
||||||
request: DeleteWarrenFileRequest,
|
request: WarrenSaveRequest,
|
||||||
) -> impl Future<Output = Result<DeleteWarrenFileResponse, DeleteWarrenFileError>> + Send;
|
) -> impl Future<Output = Result<WarrenSaveResponse, WarrenSaveError>> + Send;
|
||||||
|
fn warren_touch(
|
||||||
fn rename_warren_entry(
|
|
||||||
&self,
|
&self,
|
||||||
request: RenameWarrenEntryRequest,
|
request: WarrenTouchRequest,
|
||||||
) -> impl Future<Output = Result<RenameWarrenEntryResponse, RenameWarrenEntryError>> + Send;
|
) -> impl Future<Output = Result<WarrenTouchResponse, WarrenTouchError>> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FileSystemService: Clone + Send + Sync + 'static {
|
pub trait FileSystemService: Clone + Send + Sync + 'static {
|
||||||
fn list_files(
|
fn ls(&self, request: LsRequest) -> impl Future<Output = Result<Vec<File>, LsError>> + Send;
|
||||||
|
fn cat(&self, request: CatRequest)
|
||||||
|
-> impl Future<Output = Result<FileStream, CatError>> + Send;
|
||||||
|
fn mkdir(&self, request: MkdirRequest) -> impl Future<Output = Result<(), MkdirError>> + Send;
|
||||||
|
fn rm(&self, request: RmRequest) -> impl Future<Output = Result<(), RmError>> + Send;
|
||||||
|
fn mv(&self, request: MvRequest) -> impl Future<Output = Result<(), MvError>> + Send;
|
||||||
|
fn save(
|
||||||
&self,
|
&self,
|
||||||
request: ListFilesRequest,
|
request: SaveRequest,
|
||||||
) -> impl Future<Output = Result<Vec<File>, ListFilesError>> + Send;
|
) -> impl Future<Output = Result<SaveResponse, SaveError>> + Send;
|
||||||
|
fn touch(&self, request: TouchRequest) -> impl Future<Output = Result<(), TouchError>> + Send;
|
||||||
fn create_directory(
|
|
||||||
&self,
|
|
||||||
request: CreateDirectoryRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, CreateDirectoryError>> + Send;
|
|
||||||
fn delete_directory(
|
|
||||||
&self,
|
|
||||||
request: DeleteDirectoryRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, DeleteDirectoryError>> + Send;
|
|
||||||
|
|
||||||
fn create_file(
|
|
||||||
&self,
|
|
||||||
request: CreateFileRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, CreateFileError>> + Send;
|
|
||||||
fn fetch_file(
|
|
||||||
&self,
|
|
||||||
request: FetchFileRequest,
|
|
||||||
) -> impl Future<Output = Result<FileStream, FetchFileError>> + Send;
|
|
||||||
fn delete_file(
|
|
||||||
&self,
|
|
||||||
request: DeleteFileRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, DeleteFileError>> + Send;
|
|
||||||
|
|
||||||
fn rename_entry(
|
|
||||||
&self,
|
|
||||||
request: RenameEntryRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, RenameEntryError>> + Send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AuthService: Clone + Send + Sync + 'static {
|
pub trait AuthService: Clone + Send + Sync + 'static {
|
||||||
@@ -245,48 +217,39 @@ pub trait AuthService: Clone + Send + Sync + 'static {
|
|||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<Output = Result<Warren, AuthError<FetchWarrenError>>> + Send;
|
) -> impl Future<Output = Result<Warren, AuthError<FetchWarrenError>>> + Send;
|
||||||
|
|
||||||
fn fetch_warren_file<WS: WarrenService>(
|
fn auth_warren_ls<WS: WarrenService>(
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<FetchWarrenFileRequest>,
|
request: AuthRequest<WarrenLsRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<Output = Result<FileStream, AuthError<FetchWarrenFileError>>> + Send;
|
) -> impl Future<Output = Result<WarrenLsResponse, AuthError<WarrenLsError>>> + Send;
|
||||||
|
fn auth_warren_cat<WS: WarrenService>(
|
||||||
fn list_warren_files<WS: WarrenService>(
|
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<ListWarrenFilesRequest>,
|
request: AuthRequest<WarrenCatRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<Output = Result<ListWarrenFilesResponse, AuthError<ListWarrenFilesError>>> + Send;
|
) -> impl Future<Output = Result<FileStream, AuthError<WarrenCatError>>> + Send;
|
||||||
|
fn auth_warren_mkdir<WS: WarrenService>(
|
||||||
fn create_warren_directory<WS: WarrenService>(
|
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<CreateWarrenDirectoryRequest>,
|
request: AuthRequest<WarrenMkdirRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<
|
) -> impl Future<Output = Result<WarrenMkdirResponse, AuthError<WarrenMkdirError>>> + Send;
|
||||||
Output = Result<CreateWarrenDirectoryResponse, AuthError<CreateWarrenDirectoryError>>,
|
fn auth_warren_rm<WS: WarrenService>(
|
||||||
> + Send;
|
|
||||||
|
|
||||||
fn delete_warren_directory<WS: WarrenService>(
|
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<DeleteWarrenDirectoryRequest>,
|
request: AuthRequest<WarrenRmRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<
|
) -> impl Future<Output = Result<WarrenRmResponse, AuthError<WarrenRmError>>> + Send;
|
||||||
Output = Result<DeleteWarrenDirectoryResponse, AuthError<DeleteWarrenDirectoryError>>,
|
fn auth_warren_mv<WS: WarrenService>(
|
||||||
> + Send;
|
|
||||||
|
|
||||||
fn upload_warren_files<WS: WarrenService>(
|
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<UploadWarrenFilesRequest>,
|
request: AuthRequest<WarrenMvRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<Output = Result<UploadWarrenFilesResponse, AuthError<UploadWarrenFilesError>>> + Send;
|
) -> impl Future<Output = Result<WarrenMvResponse, AuthError<WarrenMvError>>> + Send;
|
||||||
fn delete_warren_file<WS: WarrenService>(
|
fn auth_warren_save<WS: WarrenService>(
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<DeleteWarrenFileRequest>,
|
request: AuthRequest<WarrenSaveRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<Output = Result<DeleteWarrenFileResponse, AuthError<DeleteWarrenFileError>>> + Send;
|
) -> impl Future<Output = Result<WarrenSaveResponse, AuthError<WarrenSaveError>>> + Send;
|
||||||
|
fn auth_warren_touch<WS: WarrenService>(
|
||||||
fn rename_warren_entry<WS: WarrenService>(
|
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<RenameWarrenEntryRequest>,
|
request: AuthRequest<WarrenTouchRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> impl Future<Output = Result<RenameWarrenEntryResponse, AuthError<RenameWarrenEntryError>>> + Send;
|
) -> impl Future<Output = Result<WarrenTouchResponse, AuthError<WarrenTouchError>>> + Send;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use crate::domain::warren::models::{
|
use crate::domain::warren::models::{
|
||||||
auth_session::requests::FetchAuthSessionResponse,
|
auth_session::requests::FetchAuthSessionResponse,
|
||||||
file::{AbsoluteFilePath, File, FilePath},
|
file::{AbsoluteFilePath, File},
|
||||||
user::{ListAllUsersAndWarrensResponse, LoginUserResponse, User},
|
user::{ListAllUsersAndWarrensResponse, LoginUserResponse, User},
|
||||||
user_warren::UserWarren,
|
user_warren::UserWarren,
|
||||||
warren::{
|
warren::{
|
||||||
CreateWarrenDirectoryResponse, DeleteWarrenDirectoryResponse, DeleteWarrenFileResponse,
|
Warren, WarrenLsResponse, WarrenMkdirResponse, WarrenMvResponse, WarrenRmResponse,
|
||||||
ListWarrenFilesResponse, RenameWarrenEntryResponse, UploadWarrenFilesResponse, Warren,
|
WarrenSaveResponse, WarrenTouchResponse,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,67 +19,44 @@ pub trait WarrenNotifier: Clone + Send + Sync + 'static {
|
|||||||
fn warrens_fetched(&self, warrens: &Vec<Warren>) -> impl Future<Output = ()> + Send;
|
fn warrens_fetched(&self, warrens: &Vec<Warren>) -> impl Future<Output = ()> + Send;
|
||||||
fn warren_fetched(&self, warren: &Warren) -> impl Future<Output = ()> + Send;
|
fn warren_fetched(&self, warren: &Warren) -> impl Future<Output = ()> + Send;
|
||||||
fn warrens_listed(&self, warrens: &Vec<Warren>) -> impl Future<Output = ()> + Send;
|
fn warrens_listed(&self, warrens: &Vec<Warren>) -> impl Future<Output = ()> + Send;
|
||||||
fn warren_files_listed(
|
|
||||||
&self,
|
|
||||||
response: &ListWarrenFilesResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
|
||||||
fn warren_directory_created(
|
|
||||||
&self,
|
|
||||||
response: &CreateWarrenDirectoryResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
|
||||||
fn warren_directory_deleted(
|
|
||||||
&self,
|
|
||||||
response: &DeleteWarrenDirectoryResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn warren_file_fetched(
|
fn warren_ls(&self, response: &WarrenLsResponse) -> impl Future<Output = ()> + Send;
|
||||||
|
fn warren_cat(
|
||||||
&self,
|
&self,
|
||||||
warren: &Warren,
|
warren: &Warren,
|
||||||
path: &AbsoluteFilePath,
|
path: &AbsoluteFilePath,
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
fn warren_mkdir(&self, response: &WarrenMkdirResponse) -> impl Future<Output = ()> + Send;
|
||||||
|
fn warren_rm(&self, response: &WarrenRmResponse) -> impl Future<Output = ()> + Send;
|
||||||
|
fn warren_mv(&self, response: &WarrenMvResponse) -> impl Future<Output = ()> + Send;
|
||||||
/// A single file was uploaded
|
/// A single file was uploaded
|
||||||
///
|
///
|
||||||
/// * `warren`: The warren the file was uploaded to
|
/// * `warren`: The warren the file was uploaded to
|
||||||
/// * `path`: The file's path
|
/// * `path`: The file's path
|
||||||
fn warren_file_uploaded(
|
fn warren_save(
|
||||||
&self,
|
&self,
|
||||||
warren: &Warren,
|
warren: &Warren,
|
||||||
path: &FilePath,
|
path: &AbsoluteFilePath,
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
/// A collection of files was uploaded
|
fn warren_touch(
|
||||||
///
|
|
||||||
/// * `warren`: The warren the file was uploaded to
|
|
||||||
/// * `files`: The files' paths
|
|
||||||
fn warren_files_uploaded(
|
|
||||||
&self,
|
&self,
|
||||||
response: &UploadWarrenFilesResponse,
|
warren: &Warren,
|
||||||
) -> impl Future<Output = ()> + Send;
|
path: &AbsoluteFilePath,
|
||||||
fn warren_file_deleted(
|
|
||||||
&self,
|
|
||||||
response: &DeleteWarrenFileResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn warren_entry_renamed(
|
|
||||||
&self,
|
|
||||||
response: &RenameWarrenEntryResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FileSystemNotifier: Clone + Send + Sync + 'static {
|
pub trait FileSystemNotifier: Clone + Send + Sync + 'static {
|
||||||
fn files_listed(&self, files: &Vec<File>) -> impl Future<Output = ()> + Send;
|
fn ls(&self, files: &Vec<File>) -> impl Future<Output = ()> + Send;
|
||||||
|
fn cat(&self, path: &AbsoluteFilePath) -> impl Future<Output = ()> + Send;
|
||||||
fn directory_created(&self, path: &FilePath) -> impl Future<Output = ()> + Send;
|
fn mkdir(&self, path: &AbsoluteFilePath) -> impl Future<Output = ()> + Send;
|
||||||
fn directory_deleted(&self, path: &FilePath) -> impl Future<Output = ()> + Send;
|
fn rm(&self, path: &AbsoluteFilePath) -> impl Future<Output = ()> + Send;
|
||||||
|
fn mv(
|
||||||
fn file_created(&self, path: &FilePath) -> impl Future<Output = ()> + Send;
|
|
||||||
fn file_fetched(&self, path: &AbsoluteFilePath) -> impl Future<Output = ()> + Send;
|
|
||||||
fn file_deleted(&self, path: &FilePath) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn entry_renamed(
|
|
||||||
&self,
|
&self,
|
||||||
old_path: &FilePath,
|
old_path: &AbsoluteFilePath,
|
||||||
new_path: &FilePath,
|
new_path: &AbsoluteFilePath,
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
fn save(&self, path: &AbsoluteFilePath) -> impl Future<Output = ()> + Send;
|
||||||
|
fn touch(&self, path: &AbsoluteFilePath) -> impl Future<Output = ()> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AuthNotifier: Clone + Send + Sync + 'static {
|
pub trait AuthNotifier: Clone + Send + Sync + 'static {
|
||||||
@@ -145,47 +122,42 @@ pub trait AuthNotifier: Clone + Send + Sync + 'static {
|
|||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
|
||||||
fn auth_warren_fetched(&self, user: &User, warren: &Warren) -> impl Future<Output = ()> + Send;
|
fn auth_warren_fetched(&self, user: &User, warren: &Warren) -> impl Future<Output = ()> + Send;
|
||||||
fn auth_warren_files_listed(
|
|
||||||
&self,
|
|
||||||
user: &User,
|
|
||||||
response: &ListWarrenFilesResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
|
||||||
fn auth_warren_directory_created(
|
|
||||||
&self,
|
|
||||||
user: &User,
|
|
||||||
response: &CreateWarrenDirectoryResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
|
||||||
fn auth_warren_directory_deleted(
|
|
||||||
&self,
|
|
||||||
user: &User,
|
|
||||||
response: &DeleteWarrenDirectoryResponse,
|
|
||||||
) -> impl Future<Output = ()> + Send;
|
|
||||||
|
|
||||||
fn auth_warren_file_fetched(
|
fn auth_warren_ls(
|
||||||
|
&self,
|
||||||
|
user: &User,
|
||||||
|
response: &WarrenLsResponse,
|
||||||
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
fn auth_warren_cat(
|
||||||
&self,
|
&self,
|
||||||
user: &User,
|
user: &User,
|
||||||
warren_id: &Uuid,
|
warren_id: &Uuid,
|
||||||
path: &AbsoluteFilePath,
|
path: &AbsoluteFilePath,
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
fn auth_warren_mkdir(
|
||||||
/// A collection of files was uploaded
|
|
||||||
///
|
|
||||||
/// * `warren`: The warren the file was uploaded to
|
|
||||||
/// * `files`: The files' paths
|
|
||||||
fn auth_warren_files_uploaded(
|
|
||||||
&self,
|
&self,
|
||||||
user: &User,
|
user: &User,
|
||||||
response: &UploadWarrenFilesResponse,
|
response: &WarrenMkdirResponse,
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
fn auth_warren_file_deleted(
|
fn auth_warren_rm(
|
||||||
&self,
|
&self,
|
||||||
user: &User,
|
user: &User,
|
||||||
response: &DeleteWarrenFileResponse,
|
response: &WarrenRmResponse,
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
fn auth_warren_mv(
|
||||||
fn auth_warren_entry_renamed(
|
|
||||||
&self,
|
&self,
|
||||||
user: &User,
|
user: &User,
|
||||||
response: &RenameWarrenEntryResponse,
|
response: &WarrenMvResponse,
|
||||||
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
/// A file was uploaded
|
||||||
|
fn auth_warren_save(
|
||||||
|
&self,
|
||||||
|
user: &User,
|
||||||
|
response: &WarrenSaveResponse,
|
||||||
|
) -> impl Future<Output = ()> + Send;
|
||||||
|
fn auth_warren_touch(
|
||||||
|
&self,
|
||||||
|
user: &User,
|
||||||
|
response: &WarrenTouchResponse,
|
||||||
) -> impl Future<Output = ()> + Send;
|
) -> impl Future<Output = ()> + Send;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ use crate::domain::warren::models::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
file::{
|
file::{
|
||||||
CreateDirectoryError, CreateDirectoryRequest, CreateFileError, CreateFileRequest,
|
CatError, CatRequest, File, FileStream, LsError, LsRequest, MkdirError, MkdirRequest,
|
||||||
DeleteDirectoryError, DeleteDirectoryRequest, DeleteFileError, DeleteFileRequest,
|
MvError, MvRequest, RmError, RmRequest, SaveError, SaveRequest, SaveResponse, TouchError,
|
||||||
FetchFileError, FetchFileRequest, File, FilePath, FileStream, ListFilesError,
|
TouchRequest,
|
||||||
ListFilesRequest, RenameEntryError, RenameEntryRequest,
|
|
||||||
},
|
},
|
||||||
user::{
|
user::{
|
||||||
CreateUserError, CreateUserRequest, DeleteUserError, DeleteUserRequest, EditUserError,
|
CreateUserError, CreateUserRequest, DeleteUserError, DeleteUserRequest, EditUserError,
|
||||||
@@ -67,37 +66,17 @@ pub trait WarrenRepository: Clone + Send + Sync + 'static {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait FileSystemRepository: Clone + Send + Sync + 'static {
|
pub trait FileSystemRepository: Clone + Send + Sync + 'static {
|
||||||
fn list_files(
|
fn ls(&self, request: LsRequest) -> impl Future<Output = Result<Vec<File>, LsError>> + Send;
|
||||||
|
fn cat(&self, request: CatRequest)
|
||||||
|
-> impl Future<Output = Result<FileStream, CatError>> + Send;
|
||||||
|
fn mkdir(&self, request: MkdirRequest) -> impl Future<Output = Result<(), MkdirError>> + Send;
|
||||||
|
fn rm(&self, request: RmRequest) -> impl Future<Output = Result<(), RmError>> + Send;
|
||||||
|
fn mv(&self, request: MvRequest) -> impl Future<Output = Result<(), MvError>> + Send;
|
||||||
|
fn save(
|
||||||
&self,
|
&self,
|
||||||
request: ListFilesRequest,
|
request: SaveRequest,
|
||||||
) -> impl Future<Output = Result<Vec<File>, ListFilesError>> + Send;
|
) -> impl Future<Output = Result<SaveResponse, SaveError>> + Send;
|
||||||
|
fn touch(&self, request: TouchRequest) -> impl Future<Output = Result<(), TouchError>> + Send;
|
||||||
fn create_directory(
|
|
||||||
&self,
|
|
||||||
request: CreateDirectoryRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, CreateDirectoryError>> + Send;
|
|
||||||
fn delete_directory(
|
|
||||||
&self,
|
|
||||||
request: DeleteDirectoryRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, DeleteDirectoryError>> + Send;
|
|
||||||
|
|
||||||
fn create_file(
|
|
||||||
&self,
|
|
||||||
request: CreateFileRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, CreateFileError>> + Send;
|
|
||||||
fn fetch_file(
|
|
||||||
&self,
|
|
||||||
request: FetchFileRequest,
|
|
||||||
) -> impl Future<Output = Result<FileStream, FetchFileError>> + Send;
|
|
||||||
fn delete_file(
|
|
||||||
&self,
|
|
||||||
request: DeleteFileRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, DeleteFileError>> + Send;
|
|
||||||
|
|
||||||
fn rename_entry(
|
|
||||||
&self,
|
|
||||||
request: RenameEntryRequest,
|
|
||||||
) -> impl Future<Output = Result<FilePath, RenameEntryError>> + Send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AuthRepository: Clone + Send + Sync + 'static {
|
pub trait AuthRepository: Clone + Send + Sync + 'static {
|
||||||
|
|||||||
@@ -26,17 +26,14 @@ use crate::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
warren::{
|
warren::{
|
||||||
CreateWarrenDirectoryError, CreateWarrenDirectoryRequest,
|
CreateWarrenError, CreateWarrenRequest, DeleteWarrenError, DeleteWarrenRequest,
|
||||||
CreateWarrenDirectoryResponse, CreateWarrenError, CreateWarrenRequest,
|
EditWarrenError, EditWarrenRequest, FetchWarrenError, FetchWarrenRequest,
|
||||||
DeleteWarrenDirectoryError, DeleteWarrenDirectoryRequest,
|
FetchWarrensRequest, Warren, WarrenCatError, WarrenCatRequest, WarrenLsError,
|
||||||
DeleteWarrenDirectoryResponse, DeleteWarrenError, DeleteWarrenFileError,
|
WarrenLsRequest, WarrenLsResponse, WarrenMkdirError, WarrenMkdirRequest,
|
||||||
DeleteWarrenFileRequest, DeleteWarrenFileResponse, DeleteWarrenRequest,
|
WarrenMkdirResponse, WarrenMvError, WarrenMvRequest, WarrenMvResponse,
|
||||||
EditWarrenError, EditWarrenRequest, FetchWarrenError, FetchWarrenFileError,
|
WarrenRmError, WarrenRmRequest, WarrenRmResponse, WarrenSaveError,
|
||||||
FetchWarrenFileRequest, FetchWarrenRequest, FetchWarrensRequest,
|
WarrenSaveRequest, WarrenSaveResponse, WarrenTouchError, WarrenTouchRequest,
|
||||||
ListWarrenFilesError, ListWarrenFilesRequest, ListWarrenFilesResponse,
|
WarrenTouchResponse,
|
||||||
RenameWarrenEntryError, RenameWarrenEntryRequest, RenameWarrenEntryResponse,
|
|
||||||
UploadWarrenFilesError, UploadWarrenFilesRequest, UploadWarrenFilesResponse,
|
|
||||||
Warren,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ports::{AuthMetrics, AuthNotifier, AuthRepository, AuthService, WarrenService},
|
ports::{AuthMetrics, AuthNotifier, AuthRepository, AuthService, WarrenService},
|
||||||
@@ -577,23 +574,60 @@ where
|
|||||||
.fetch_warrens(FetchWarrensRequest::new(
|
.fetch_warrens(FetchWarrensRequest::new(
|
||||||
ids.into_iter().map(|uw| uw.into_warren_id()).collect(),
|
ids.into_iter().map(|uw| uw.into_warren_id()).collect(),
|
||||||
))
|
))
|
||||||
.await;
|
.await
|
||||||
|
.map_err(|e| AuthError::Custom(e.into()));
|
||||||
|
|
||||||
result.map_err(|e| AuthError::Custom(e.into()))
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_warren_file<WS: WarrenService>(
|
async fn auth_warren_ls<WS: WarrenService>(
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<FetchWarrenFileRequest>,
|
request: AuthRequest<WarrenLsRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> Result<FileStream, AuthError<FetchWarrenFileError>> {
|
) -> Result<WarrenLsResponse, AuthError<WarrenLsError>> {
|
||||||
let (session, request) = request.unpack();
|
let session_response = self.fetch_auth_session((&request).into()).await?;
|
||||||
|
|
||||||
let path = request.path().clone();
|
let request = request.into_value();
|
||||||
let session_response = self
|
|
||||||
.fetch_auth_session(FetchAuthSessionRequest::new(session.session_id().clone()))
|
let user_warren = self
|
||||||
|
.repository
|
||||||
|
.fetch_user_warren(FetchUserWarrenRequest::new(
|
||||||
|
session_response.user().id().clone(),
|
||||||
|
request.warren_id().clone(),
|
||||||
|
))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
if !user_warren.can_list_files() {
|
||||||
|
return Err(AuthError::InsufficientPermissions);
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = warren_service
|
||||||
|
.warren_ls(request)
|
||||||
|
.await
|
||||||
|
.map_err(AuthError::Custom);
|
||||||
|
|
||||||
|
if let Ok(response) = result.as_ref() {
|
||||||
|
self.metrics.record_auth_warren_ls_success().await;
|
||||||
|
self.notifier
|
||||||
|
.auth_warren_ls(session_response.user(), response)
|
||||||
|
.await;
|
||||||
|
} else {
|
||||||
|
self.metrics.record_auth_warren_ls_failure().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn auth_warren_cat<WS: WarrenService>(
|
||||||
|
&self,
|
||||||
|
request: AuthRequest<WarrenCatRequest>,
|
||||||
|
warren_service: &WS,
|
||||||
|
) -> Result<FileStream, AuthError<WarrenCatError>> {
|
||||||
|
let session_response = self.fetch_auth_session((&request).into()).await?;
|
||||||
|
|
||||||
|
let request = request.into_value();
|
||||||
|
let path = request.base().path().clone();
|
||||||
|
|
||||||
let user_warren = self
|
let user_warren = self
|
||||||
.repository
|
.repository
|
||||||
.fetch_user_warren(FetchUserWarrenRequest::new(
|
.fetch_user_warren(FetchUserWarrenRequest::new(
|
||||||
@@ -607,106 +641,30 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
let result = warren_service
|
let result = warren_service
|
||||||
.fetch_warren_file(request)
|
.warren_cat(request)
|
||||||
.await
|
.await
|
||||||
.map_err(AuthError::Custom);
|
.map_err(AuthError::Custom);
|
||||||
|
|
||||||
if let Ok(_stream) = result.as_ref() {
|
if let Ok(_stream) = result.as_ref() {
|
||||||
self.metrics.record_auth_warren_fetch_file_success().await;
|
self.metrics.record_auth_warren_cat_success().await;
|
||||||
self.notifier
|
self.notifier
|
||||||
.auth_warren_file_fetched(session_response.user(), user_warren.warren_id(), &path)
|
.auth_warren_cat(session_response.user(), user_warren.warren_id(), &path)
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_auth_warren_fetch_file_failure().await;
|
self.metrics.record_auth_warren_cat_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_warren_files<WS: WarrenService>(
|
async fn auth_warren_mkdir<WS: WarrenService>(
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<ListWarrenFilesRequest>,
|
request: AuthRequest<WarrenMkdirRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> Result<ListWarrenFilesResponse, AuthError<ListWarrenFilesError>> {
|
) -> Result<WarrenMkdirResponse, AuthError<WarrenMkdirError>> {
|
||||||
let (session, request) = request.unpack();
|
let session_response = self.fetch_auth_session((&request).into()).await?;
|
||||||
|
|
||||||
let session_response = self
|
let request = request.into_value();
|
||||||
.fetch_auth_session(FetchAuthSessionRequest::new(session.session_id().clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let user_warren = self
|
|
||||||
.repository
|
|
||||||
.fetch_user_warren(FetchUserWarrenRequest::new(
|
|
||||||
session_response.user().id().clone(),
|
|
||||||
request.warren_id().clone(),
|
|
||||||
))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if !user_warren.can_list_files() {
|
|
||||||
return Err(AuthError::InsufficientPermissions);
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = warren_service.list_warren_files(request).await;
|
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
|
||||||
self.metrics.record_auth_warren_file_list_success().await;
|
|
||||||
self.notifier
|
|
||||||
.auth_warren_files_listed(session_response.user(), response)
|
|
||||||
.await;
|
|
||||||
} else {
|
|
||||||
self.metrics.record_auth_warren_file_list_failure().await;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.map_err(AuthError::Custom)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn rename_warren_entry<WS: WarrenService>(
|
|
||||||
&self,
|
|
||||||
request: AuthRequest<RenameWarrenEntryRequest>,
|
|
||||||
warren_service: &WS,
|
|
||||||
) -> Result<RenameWarrenEntryResponse, AuthError<RenameWarrenEntryError>> {
|
|
||||||
let (session, request) = request.unpack();
|
|
||||||
|
|
||||||
let session_response = self
|
|
||||||
.fetch_auth_session(FetchAuthSessionRequest::new(session.session_id().clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let user_warren = self
|
|
||||||
.repository
|
|
||||||
.fetch_user_warren(FetchUserWarrenRequest::new(
|
|
||||||
session_response.user().id().clone(),
|
|
||||||
request.warren_id().clone(),
|
|
||||||
))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if !user_warren.can_modify_files() {
|
|
||||||
return Err(AuthError::InsufficientPermissions);
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = warren_service.rename_warren_entry(request).await;
|
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
|
||||||
self.metrics.record_auth_warren_entry_rename_success().await;
|
|
||||||
self.notifier
|
|
||||||
.auth_warren_entry_renamed(session_response.user(), response)
|
|
||||||
.await;
|
|
||||||
} else {
|
|
||||||
self.metrics.record_auth_warren_entry_rename_failure().await;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.map_err(AuthError::Custom)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn create_warren_directory<WS: WarrenService>(
|
|
||||||
&self,
|
|
||||||
request: AuthRequest<CreateWarrenDirectoryRequest>,
|
|
||||||
warren_service: &WS,
|
|
||||||
) -> Result<CreateWarrenDirectoryResponse, AuthError<CreateWarrenDirectoryError>> {
|
|
||||||
let (session, request) = request.unpack();
|
|
||||||
|
|
||||||
let session_response = self
|
|
||||||
.fetch_auth_session(FetchAuthSessionRequest::new(session.session_id().clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let user_warren = self
|
let user_warren = self
|
||||||
.repository
|
.repository
|
||||||
@@ -721,34 +679,31 @@ where
|
|||||||
return Err(AuthError::InsufficientPermissions);
|
return Err(AuthError::InsufficientPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = warren_service.create_warren_directory(request).await;
|
let result = warren_service
|
||||||
|
.warren_mkdir(request)
|
||||||
|
.await
|
||||||
|
.map_err(AuthError::Custom);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics
|
self.metrics.record_auth_warren_mkdir_success().await;
|
||||||
.record_auth_warren_directory_creation_success()
|
|
||||||
.await;
|
|
||||||
self.notifier
|
self.notifier
|
||||||
.auth_warren_directory_created(session_response.user(), response)
|
.auth_warren_mkdir(session_response.user(), response)
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics
|
self.metrics.record_auth_warren_mkdir_failure().await;
|
||||||
.record_auth_warren_directory_creation_failure()
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(AuthError::Custom)
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_warren_file<WS: WarrenService>(
|
async fn auth_warren_rm<WS: WarrenService>(
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<DeleteWarrenFileRequest>,
|
request: AuthRequest<WarrenRmRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> Result<DeleteWarrenFileResponse, AuthError<DeleteWarrenFileError>> {
|
) -> Result<WarrenRmResponse, AuthError<WarrenRmError>> {
|
||||||
let (session, request) = request.unpack();
|
let session_response = self.fetch_auth_session((&request).into()).await?;
|
||||||
|
|
||||||
let session_response = self
|
let request = request.into_value();
|
||||||
.fetch_auth_session(FetchAuthSessionRequest::new(session.session_id().clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let user_warren = self
|
let user_warren = self
|
||||||
.repository
|
.repository
|
||||||
@@ -762,34 +717,31 @@ where
|
|||||||
return Err(AuthError::InsufficientPermissions);
|
return Err(AuthError::InsufficientPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = warren_service.delete_warren_file(request).await;
|
let result = warren_service
|
||||||
|
.warren_rm(request)
|
||||||
|
.await
|
||||||
|
.map_err(AuthError::Custom);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics
|
self.metrics.record_auth_warren_rm_success().await;
|
||||||
.record_auth_warren_file_deletion_success()
|
|
||||||
.await;
|
|
||||||
self.notifier
|
self.notifier
|
||||||
.auth_warren_file_deleted(session_response.user(), response)
|
.auth_warren_rm(session_response.user(), response)
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics
|
self.metrics.record_auth_warren_rm_failure().await;
|
||||||
.record_auth_warren_file_deletion_failure()
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(AuthError::Custom)
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_warren_directory<WS: WarrenService>(
|
async fn auth_warren_mv<WS: WarrenService>(
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<DeleteWarrenDirectoryRequest>,
|
request: AuthRequest<WarrenMvRequest>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> Result<DeleteWarrenDirectoryResponse, AuthError<DeleteWarrenDirectoryError>> {
|
) -> Result<WarrenMvResponse, AuthError<WarrenMvError>> {
|
||||||
let (session, request) = request.unpack();
|
let session_response = self.fetch_auth_session((&request).into()).await?;
|
||||||
|
|
||||||
let session_response = self
|
let request = request.into_value();
|
||||||
.fetch_auth_session(FetchAuthSessionRequest::new(session.session_id().clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let user_warren = self
|
let user_warren = self
|
||||||
.repository
|
.repository
|
||||||
@@ -799,38 +751,35 @@ where
|
|||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if !user_warren.can_delete_files() {
|
if !user_warren.can_modify_files() {
|
||||||
return Err(AuthError::InsufficientPermissions);
|
return Err(AuthError::InsufficientPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = warren_service.delete_warren_directory(request).await;
|
let result = warren_service
|
||||||
|
.warren_mv(request)
|
||||||
|
.await
|
||||||
|
.map_err(AuthError::Custom);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics
|
self.metrics.record_auth_warren_mv_success().await;
|
||||||
.record_auth_warren_directory_deletion_success()
|
|
||||||
.await;
|
|
||||||
self.notifier
|
self.notifier
|
||||||
.auth_warren_directory_deleted(session_response.user(), response)
|
.auth_warren_mv(session_response.user(), response)
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics
|
self.metrics.record_auth_warren_mv_failure().await;
|
||||||
.record_auth_warren_directory_deletion_failure()
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(AuthError::Custom)
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn upload_warren_files<WS: WarrenService>(
|
async fn auth_warren_save<WS: WarrenService>(
|
||||||
&self,
|
&self,
|
||||||
request: AuthRequest<UploadWarrenFilesRequest>,
|
request: AuthRequest<WarrenSaveRequest<'_>>,
|
||||||
warren_service: &WS,
|
warren_service: &WS,
|
||||||
) -> Result<UploadWarrenFilesResponse, AuthError<UploadWarrenFilesError>> {
|
) -> Result<WarrenSaveResponse, AuthError<WarrenSaveError>> {
|
||||||
let (session, request) = request.unpack();
|
let session_response = self.fetch_auth_session((&request).into()).await?;
|
||||||
|
|
||||||
let session_response = self
|
let request = request.into_value();
|
||||||
.fetch_auth_session(FetchAuthSessionRequest::new(session.session_id().clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let user_warren = self
|
let user_warren = self
|
||||||
.repository
|
.repository
|
||||||
@@ -845,17 +794,59 @@ where
|
|||||||
return Err(AuthError::InsufficientPermissions);
|
return Err(AuthError::InsufficientPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = warren_service.upload_warren_files(request).await;
|
let result = warren_service
|
||||||
|
.warren_save(request)
|
||||||
|
.await
|
||||||
|
.map_err(AuthError::Custom);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics.record_auth_warren_files_upload_success().await;
|
self.metrics.record_auth_warren_save_success().await;
|
||||||
self.notifier
|
self.notifier
|
||||||
.auth_warren_files_uploaded(session_response.user(), response)
|
.auth_warren_save(session_response.user(), response)
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_auth_warren_files_upload_failure().await;
|
self.metrics.record_auth_warren_save_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(AuthError::Custom)
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn auth_warren_touch<WS: WarrenService>(
|
||||||
|
&self,
|
||||||
|
request: AuthRequest<WarrenTouchRequest>,
|
||||||
|
warren_service: &WS,
|
||||||
|
) -> Result<WarrenTouchResponse, AuthError<WarrenTouchError>> {
|
||||||
|
let session_response = self.fetch_auth_session((&request).into()).await?;
|
||||||
|
|
||||||
|
let request = request.into_value();
|
||||||
|
|
||||||
|
let user_warren = self
|
||||||
|
.repository
|
||||||
|
.fetch_user_warren(FetchUserWarrenRequest::new(
|
||||||
|
session_response.user().id().clone(),
|
||||||
|
request.warren_id().clone(),
|
||||||
|
))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
// TODO: Maybe create a separate permission for this
|
||||||
|
if !user_warren.can_modify_files() {
|
||||||
|
return Err(AuthError::InsufficientPermissions);
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = warren_service
|
||||||
|
.warren_touch(request)
|
||||||
|
.await
|
||||||
|
.map_err(AuthError::Custom);
|
||||||
|
|
||||||
|
if let Ok(response) = result.as_ref() {
|
||||||
|
self.metrics.record_auth_warren_save_success().await;
|
||||||
|
self.notifier
|
||||||
|
.auth_warren_touch(session_response.user(), response)
|
||||||
|
.await;
|
||||||
|
} else {
|
||||||
|
self.metrics.record_auth_warren_save_failure().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
use crate::domain::warren::{
|
use crate::domain::warren::{
|
||||||
models::file::{
|
models::file::{
|
||||||
CreateDirectoryError, CreateDirectoryRequest, CreateFileError, CreateFileRequest,
|
CatError, CatRequest, File, FileStream, LsError, LsRequest, MkdirError, MkdirRequest,
|
||||||
DeleteDirectoryError, DeleteDirectoryRequest, DeleteFileError, DeleteFileRequest,
|
MvError, MvRequest, RmError, RmRequest, SaveError, SaveRequest, SaveResponse, TouchError,
|
||||||
FetchFileError, FetchFileRequest, File, FilePath, FileStream, ListFilesError,
|
TouchRequest,
|
||||||
ListFilesRequest, RenameEntryError, RenameEntryRequest,
|
|
||||||
},
|
},
|
||||||
ports::{FileSystemMetrics, FileSystemNotifier, FileSystemRepository, FileSystemService},
|
ports::{FileSystemMetrics, FileSystemNotifier, FileSystemRepository, FileSystemService},
|
||||||
};
|
};
|
||||||
@@ -41,103 +40,99 @@ where
|
|||||||
M: FileSystemMetrics,
|
M: FileSystemMetrics,
|
||||||
N: FileSystemNotifier,
|
N: FileSystemNotifier,
|
||||||
{
|
{
|
||||||
async fn list_files(&self, request: ListFilesRequest) -> Result<Vec<File>, ListFilesError> {
|
async fn ls(&self, request: LsRequest) -> Result<Vec<File>, LsError> {
|
||||||
let result = self.repository.list_files(request).await;
|
let result = self.repository.ls(request).await;
|
||||||
|
|
||||||
if let Ok(files) = result.as_ref() {
|
if let Ok(files) = result.as_ref() {
|
||||||
self.metrics.record_list_files_success().await;
|
self.metrics.record_ls_success().await;
|
||||||
self.notifier.files_listed(files).await;
|
self.notifier.ls(files).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_list_files_failure().await;
|
self.metrics.record_ls_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_directory(
|
async fn cat(&self, request: CatRequest) -> Result<FileStream, CatError> {
|
||||||
&self,
|
|
||||||
request: CreateDirectoryRequest,
|
|
||||||
) -> Result<FilePath, CreateDirectoryError> {
|
|
||||||
let result = self.repository.create_directory(request).await;
|
|
||||||
|
|
||||||
if let Ok(path) = result.as_ref() {
|
|
||||||
self.metrics.record_directory_creation_success().await;
|
|
||||||
self.notifier.directory_created(path).await;
|
|
||||||
} else {
|
|
||||||
self.metrics.record_directory_creation_failure().await;
|
|
||||||
}
|
|
||||||
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn delete_directory(
|
|
||||||
&self,
|
|
||||||
request: DeleteDirectoryRequest,
|
|
||||||
) -> Result<FilePath, DeleteDirectoryError> {
|
|
||||||
let result = self.repository.delete_directory(request).await;
|
|
||||||
|
|
||||||
if let Ok(path) = result.as_ref() {
|
|
||||||
self.metrics.record_directory_deletion_success().await;
|
|
||||||
self.notifier.directory_deleted(path).await;
|
|
||||||
} else {
|
|
||||||
self.metrics.record_directory_deletion_failure().await;
|
|
||||||
}
|
|
||||||
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn create_file(&self, request: CreateFileRequest) -> Result<FilePath, CreateFileError> {
|
|
||||||
let result = self.repository.create_file(request).await;
|
|
||||||
|
|
||||||
if let Ok(path) = result.as_ref() {
|
|
||||||
self.metrics.record_file_creation_success().await;
|
|
||||||
self.notifier.file_created(path).await;
|
|
||||||
} else {
|
|
||||||
self.metrics.record_file_creation_failure().await;
|
|
||||||
}
|
|
||||||
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn fetch_file(&self, request: FetchFileRequest) -> Result<FileStream, FetchFileError> {
|
|
||||||
let path = request.path().clone();
|
let path = request.path().clone();
|
||||||
let result = self.repository.fetch_file(request).await;
|
let result = self.repository.cat(request).await;
|
||||||
|
|
||||||
if let Ok(_stream) = result.as_ref() {
|
if result.is_ok() {
|
||||||
self.metrics.record_file_fetch_success().await;
|
self.metrics.record_cat_success().await;
|
||||||
self.notifier.file_fetched(&path).await;
|
self.notifier.cat(&path).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_file_fetch_failure().await;
|
self.metrics.record_cat_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_file(&self, request: DeleteFileRequest) -> Result<FilePath, DeleteFileError> {
|
async fn mkdir(&self, request: MkdirRequest) -> Result<(), MkdirError> {
|
||||||
let result = self.repository.delete_file(request).await;
|
let path = request.path().clone();
|
||||||
|
let result = self.repository.mkdir(request).await;
|
||||||
|
|
||||||
if let Ok(path) = result.as_ref() {
|
if result.is_ok() {
|
||||||
self.metrics.record_file_deletion_success().await;
|
self.metrics.record_mkdir_success().await;
|
||||||
self.notifier.file_deleted(path).await;
|
self.notifier.mkdir(&path).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_file_deletion_failure().await;
|
self.metrics.record_mkdir_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn rename_entry(
|
async fn rm(&self, request: RmRequest) -> Result<(), RmError> {
|
||||||
&self,
|
let path = request.path().clone();
|
||||||
request: RenameEntryRequest,
|
let result = self.repository.rm(request).await;
|
||||||
) -> Result<FilePath, RenameEntryError> {
|
|
||||||
|
if result.is_ok() {
|
||||||
|
self.metrics.record_rm_success().await;
|
||||||
|
self.notifier.rm(&path).await;
|
||||||
|
} else {
|
||||||
|
self.metrics.record_rm_failure().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn mv(&self, request: MvRequest) -> Result<(), MvError> {
|
||||||
let old_path = request.path().clone();
|
let old_path = request.path().clone();
|
||||||
let result = self.repository.rename_entry(request).await;
|
let new_path = request.target_path().clone();
|
||||||
|
let result = self.repository.mv(request).await;
|
||||||
|
|
||||||
if let Ok(path) = result.as_ref() {
|
if result.is_ok() {
|
||||||
self.metrics.record_entry_rename_success().await;
|
self.metrics.record_mv_success().await;
|
||||||
self.notifier.entry_renamed(&old_path.into(), path).await;
|
self.notifier.mv(&old_path, &new_path).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_entry_rename_failure().await;
|
self.metrics.record_mv_failure().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn save(&self, request: SaveRequest<'_>) -> Result<SaveResponse, SaveError> {
|
||||||
|
let path = request.path().clone();
|
||||||
|
let result = self.repository.save(request).await;
|
||||||
|
|
||||||
|
if result.is_ok() {
|
||||||
|
self.metrics.record_save_success().await;
|
||||||
|
self.notifier.save(&path).await;
|
||||||
|
} else {
|
||||||
|
self.metrics.record_save_failure().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn touch(&self, request: TouchRequest) -> Result<(), TouchError> {
|
||||||
|
let path = request.path().clone();
|
||||||
|
let result = self.repository.touch(request).await;
|
||||||
|
|
||||||
|
if result.is_ok() {
|
||||||
|
self.metrics.record_touch_success().await;
|
||||||
|
self.notifier.touch(&path).await;
|
||||||
|
} else {
|
||||||
|
self.metrics.record_touch_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ use crate::domain::warren::{
|
|||||||
models::{
|
models::{
|
||||||
file::FileStream,
|
file::FileStream,
|
||||||
warren::{
|
warren::{
|
||||||
CreateWarrenDirectoryResponse, CreateWarrenError, CreateWarrenRequest,
|
CreateWarrenError, CreateWarrenRequest, DeleteWarrenError, DeleteWarrenRequest,
|
||||||
DeleteWarrenDirectoryResponse, DeleteWarrenError, DeleteWarrenFileResponse,
|
EditWarrenError, EditWarrenRequest, FetchWarrensError, FetchWarrensRequest,
|
||||||
DeleteWarrenRequest, EditWarrenError, EditWarrenRequest, FetchWarrenFileError,
|
ListWarrensError, ListWarrensRequest, WarrenCatError, WarrenCatRequest,
|
||||||
FetchWarrenFileRequest, FetchWarrensError, FetchWarrensRequest,
|
WarrenLsResponse, WarrenMkdirResponse, WarrenMvError, WarrenMvRequest,
|
||||||
ListWarrenFilesResponse, ListWarrensError, ListWarrensRequest, RenameWarrenEntryError,
|
WarrenMvResponse, WarrenRmRequest, WarrenRmResponse, WarrenSaveResponse,
|
||||||
RenameWarrenEntryRequest, RenameWarrenEntryResponse, UploadWarrenFilesResponse,
|
WarrenTouchError, WarrenTouchRequest, WarrenTouchResponse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ports::FileSystemService,
|
ports::FileSystemService,
|
||||||
@@ -15,10 +15,8 @@ use crate::domain::warren::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
super::models::warren::{
|
super::models::warren::{
|
||||||
CreateWarrenDirectoryError, CreateWarrenDirectoryRequest, DeleteWarrenDirectoryError,
|
FetchWarrenError, FetchWarrenRequest, Warren, WarrenLsError, WarrenLsRequest,
|
||||||
DeleteWarrenDirectoryRequest, DeleteWarrenFileError, DeleteWarrenFileRequest,
|
WarrenMkdirError, WarrenMkdirRequest, WarrenRmError, WarrenSaveError, WarrenSaveRequest,
|
||||||
FetchWarrenError, FetchWarrenRequest, ListWarrenFilesError, ListWarrenFilesRequest,
|
|
||||||
UploadWarrenFilesError, UploadWarrenFilesRequest, Warren,
|
|
||||||
},
|
},
|
||||||
super::ports::{WarrenMetrics, WarrenNotifier, WarrenRepository, WarrenService},
|
super::ports::{WarrenMetrics, WarrenNotifier, WarrenRepository, WarrenService},
|
||||||
};
|
};
|
||||||
@@ -149,182 +147,171 @@ where
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_warren_file(
|
async fn warren_cat(&self, request: WarrenCatRequest) -> Result<FileStream, WarrenCatError> {
|
||||||
&self,
|
|
||||||
request: FetchWarrenFileRequest,
|
|
||||||
) -> Result<FileStream, FetchWarrenFileError> {
|
|
||||||
let warren = self.repository.fetch_warren((&request).into()).await?;
|
let warren = self.repository.fetch_warren((&request).into()).await?;
|
||||||
|
|
||||||
let path = request.path().clone();
|
let path = request.base().path().clone();
|
||||||
|
let cat_request = request.build_fs_request(&warren);
|
||||||
|
|
||||||
let result = self
|
let result = self.fs_service.cat(cat_request).await.map_err(Into::into);
|
||||||
.fs_service
|
|
||||||
.fetch_file(request.to_fs_request(&warren))
|
|
||||||
.await
|
|
||||||
.map_err(Into::into);
|
|
||||||
|
|
||||||
if let Ok(_stream) = result.as_ref() {
|
if result.is_ok() {
|
||||||
self.metrics.record_warren_fetch_file_success().await;
|
self.metrics.record_warren_cat_success().await;
|
||||||
self.notifier.warren_file_fetched(&warren, &path).await;
|
self.notifier.warren_cat(&warren, &path).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_warren_fetch_file_failure().await;
|
self.metrics.record_warren_cat_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_warren_files(
|
async fn warren_ls(&self, request: WarrenLsRequest) -> Result<WarrenLsResponse, WarrenLsError> {
|
||||||
&self,
|
|
||||||
request: ListWarrenFilesRequest,
|
|
||||||
) -> Result<ListWarrenFilesResponse, ListWarrenFilesError> {
|
|
||||||
let warren = self.repository.fetch_warren(request.clone().into()).await?;
|
let warren = self.repository.fetch_warren(request.clone().into()).await?;
|
||||||
|
|
||||||
|
let path = request.base().path().clone();
|
||||||
|
let ls_request = request.build_fs_request(&warren);
|
||||||
|
|
||||||
let result = self
|
let result = self
|
||||||
.fs_service
|
.fs_service
|
||||||
.list_files(request.to_fs_request(&warren))
|
.ls(ls_request)
|
||||||
.await
|
.await
|
||||||
.map(|files| ListWarrenFilesResponse::new(warren, files));
|
.map(|files| WarrenLsResponse::new(warren, path, files))
|
||||||
|
.map_err(Into::into);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics.record_list_warren_files_success().await;
|
self.metrics.record_warren_ls_success().await;
|
||||||
self.notifier.warren_files_listed(response).await;
|
self.notifier.warren_ls(response).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_list_warren_files_failure().await;
|
self.metrics.record_warren_ls_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(Into::into)
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_warren_directory(
|
async fn warren_mkdir(
|
||||||
&self,
|
&self,
|
||||||
request: CreateWarrenDirectoryRequest,
|
request: WarrenMkdirRequest,
|
||||||
) -> Result<CreateWarrenDirectoryResponse, CreateWarrenDirectoryError> {
|
) -> Result<WarrenMkdirResponse, WarrenMkdirError> {
|
||||||
let warren = self.repository.fetch_warren(request.clone().into()).await?;
|
let warren = self.repository.fetch_warren(request.clone().into()).await?;
|
||||||
|
|
||||||
let result = self
|
let path = request.base().path().clone();
|
||||||
.fs_service
|
let mkdir_request = request.build_fs_request(&warren);
|
||||||
.create_directory(request.to_fs_request(&warren))
|
|
||||||
.await
|
|
||||||
.map(|path| CreateWarrenDirectoryResponse::new(warren, path));
|
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
|
||||||
self.metrics
|
|
||||||
.record_warren_directory_creation_success()
|
|
||||||
.await;
|
|
||||||
self.notifier.warren_directory_created(response).await;
|
|
||||||
} else {
|
|
||||||
self.metrics
|
|
||||||
.record_warren_directory_creation_failure()
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.map_err(Into::into)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn delete_warren_directory(
|
|
||||||
&self,
|
|
||||||
request: DeleteWarrenDirectoryRequest,
|
|
||||||
) -> Result<DeleteWarrenDirectoryResponse, DeleteWarrenDirectoryError> {
|
|
||||||
let warren = self.repository.fetch_warren((&request).into()).await?;
|
|
||||||
|
|
||||||
let result = self
|
let result = self
|
||||||
.fs_service
|
.fs_service
|
||||||
.delete_directory(request.to_fs_request(&warren))
|
.mkdir(mkdir_request)
|
||||||
.await
|
.await
|
||||||
.map(|path| DeleteWarrenDirectoryResponse::new(warren, path));
|
.map(|_| WarrenMkdirResponse::new(warren, path))
|
||||||
|
.map_err(Into::into);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics
|
self.metrics.record_warren_mkdir_success().await;
|
||||||
.record_warren_directory_deletion_success()
|
self.notifier.warren_mkdir(response).await;
|
||||||
.await;
|
|
||||||
self.notifier.warren_directory_deleted(response).await;
|
|
||||||
} else {
|
} else {
|
||||||
self.metrics
|
self.metrics.record_warren_mkdir_failure().await;
|
||||||
.record_warren_directory_deletion_failure()
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(Into::into)
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Improve this
|
async fn warren_save<'s>(
|
||||||
async fn upload_warren_files(
|
|
||||||
&self,
|
&self,
|
||||||
request: UploadWarrenFilesRequest,
|
request: WarrenSaveRequest<'s>,
|
||||||
) -> Result<UploadWarrenFilesResponse, UploadWarrenFilesError> {
|
) -> Result<WarrenSaveResponse, WarrenSaveError> {
|
||||||
let warren = self.repository.fetch_warren((&request).into()).await?;
|
let warren = self.repository.fetch_warren((&request).into()).await?;
|
||||||
|
|
||||||
let fs_requests = request.to_fs_requests(&warren);
|
let path = request.base().path().clone();
|
||||||
|
let save_request = request.build_fs_request(&warren);
|
||||||
|
|
||||||
let mut paths = Vec::with_capacity(fs_requests.len());
|
let result = self
|
||||||
|
.fs_service
|
||||||
|
.save(save_request)
|
||||||
|
.await
|
||||||
|
.map(|base| WarrenSaveResponse::new(warren, path, base))
|
||||||
|
.map_err(Into::into);
|
||||||
|
|
||||||
for (i, req) in fs_requests.into_iter().enumerate() {
|
if let Ok(result) = result.as_ref() {
|
||||||
let result = self.fs_service.create_file(req).await;
|
self.metrics.record_warren_save_success().await;
|
||||||
|
|
||||||
let Ok(file_path) = result else {
|
|
||||||
self.metrics.record_warren_file_upload_failure().await;
|
|
||||||
self.metrics.record_warren_files_upload_failure().await;
|
|
||||||
return Err(UploadWarrenFilesError::Partial { fail_index: i });
|
|
||||||
};
|
|
||||||
|
|
||||||
self.metrics.record_warren_file_upload_success().await;
|
|
||||||
self.notifier
|
self.notifier
|
||||||
.warren_file_uploaded(&warren, &file_path)
|
.warren_save(result.warren(), result.path())
|
||||||
.await;
|
.await;
|
||||||
|
} else {
|
||||||
paths.push(file_path);
|
self.metrics.record_warren_save_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = UploadWarrenFilesResponse::new(warren, paths);
|
result
|
||||||
|
|
||||||
self.metrics.record_warren_files_upload_success().await;
|
|
||||||
self.notifier.warren_files_uploaded(&response).await;
|
|
||||||
|
|
||||||
Ok(response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_warren_file(
|
async fn warren_rm(&self, request: WarrenRmRequest) -> Result<WarrenRmResponse, WarrenRmError> {
|
||||||
&self,
|
|
||||||
request: DeleteWarrenFileRequest,
|
|
||||||
) -> Result<DeleteWarrenFileResponse, DeleteWarrenFileError> {
|
|
||||||
let warren = self.repository.fetch_warren((&request).into()).await?;
|
let warren = self.repository.fetch_warren((&request).into()).await?;
|
||||||
|
|
||||||
|
let path = request.base().path().clone();
|
||||||
|
let rm_request = request.build_fs_request(&warren);
|
||||||
|
|
||||||
let result = self
|
let result = self
|
||||||
.fs_service
|
.fs_service
|
||||||
.delete_file(request.to_fs_request(&warren))
|
.rm(rm_request)
|
||||||
.await
|
.await
|
||||||
.map(|path| DeleteWarrenFileResponse::new(warren, path));
|
.map(|_| WarrenRmResponse::new(warren, path))
|
||||||
|
.map_err(Into::into);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics.record_warren_file_deletion_success().await;
|
self.metrics.record_warren_rm_success().await;
|
||||||
self.notifier.warren_file_deleted(response).await;
|
self.notifier.warren_rm(response).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_warren_file_deletion_failure().await;
|
self.metrics.record_warren_rm_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(Into::into)
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn rename_warren_entry(
|
async fn warren_mv(&self, request: WarrenMvRequest) -> Result<WarrenMvResponse, WarrenMvError> {
|
||||||
&self,
|
|
||||||
request: RenameWarrenEntryRequest,
|
|
||||||
) -> Result<RenameWarrenEntryResponse, RenameWarrenEntryError> {
|
|
||||||
let warren = self.repository.fetch_warren((&request).into()).await?;
|
let warren = self.repository.fetch_warren((&request).into()).await?;
|
||||||
|
|
||||||
let old_path = request.path().clone();
|
let old_path = request.base().path().clone();
|
||||||
|
let new_path = request.base().target_path().clone();
|
||||||
|
let mv_request = request.build_fs_request(&warren);
|
||||||
let result = self
|
let result = self
|
||||||
.fs_service
|
.fs_service
|
||||||
.rename_entry(request.to_fs_request(&warren))
|
.mv(mv_request)
|
||||||
.await
|
.await
|
||||||
.map(|new_path| RenameWarrenEntryResponse::new(warren, old_path, new_path));
|
.map(|_| WarrenMvResponse::new(warren, old_path, new_path))
|
||||||
|
.map_err(Into::into);
|
||||||
|
|
||||||
if let Ok(response) = result.as_ref() {
|
if let Ok(response) = result.as_ref() {
|
||||||
self.metrics.record_warren_entry_rename_success().await;
|
self.metrics.record_warren_mv_success().await;
|
||||||
self.notifier.warren_entry_renamed(response).await;
|
self.notifier.warren_mv(response).await;
|
||||||
} else {
|
} else {
|
||||||
self.metrics.record_warren_entry_rename_failure().await;
|
self.metrics.record_warren_mv_failure().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.map_err(Into::into)
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn warren_touch(
|
||||||
|
&self,
|
||||||
|
request: WarrenTouchRequest,
|
||||||
|
) -> Result<WarrenTouchResponse, WarrenTouchError> {
|
||||||
|
let warren = self.repository.fetch_warren((&request).into()).await?;
|
||||||
|
|
||||||
|
let path = request.base().path().clone();
|
||||||
|
let touch_request = request.build_fs_request(&warren);
|
||||||
|
let result = self
|
||||||
|
.fs_service
|
||||||
|
.touch(touch_request)
|
||||||
|
.await
|
||||||
|
.map(|_| WarrenTouchResponse::new(warren, path))
|
||||||
|
.map_err(Into::into);
|
||||||
|
|
||||||
|
if let Ok(response) = result.as_ref() {
|
||||||
|
self.metrics.record_warren_touch_success().await;
|
||||||
|
self.notifier
|
||||||
|
.warren_touch(response.warren(), response.path())
|
||||||
|
.await;
|
||||||
|
} else {
|
||||||
|
self.metrics.record_warren_touch_failure().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +1,55 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
domain::warren::models::{
|
domain::warren::models::{
|
||||||
auth_session::{AuthError, requests::FetchAuthSessionError},
|
auth_session::{AuthError, requests::FetchAuthSessionError},
|
||||||
file::{CreateDirectoryError, DeleteDirectoryError, DeleteFileError, ListFilesError},
|
file::{LsError, MkdirError, RmError},
|
||||||
user::{CreateUserError, LoginUserError, RegisterUserError, VerifyUserPasswordError},
|
user::{CreateUserError, LoginUserError, RegisterUserError, VerifyUserPasswordError},
|
||||||
user_warren::requests::FetchUserWarrenError,
|
user_warren::requests::FetchUserWarrenError,
|
||||||
warren::{
|
warren::{
|
||||||
CreateWarrenDirectoryError, DeleteWarrenDirectoryError, DeleteWarrenFileError,
|
FetchWarrenError, FetchWarrensError, WarrenLsError, WarrenMkdirError, WarrenMvError,
|
||||||
FetchWarrenError, FetchWarrensError, ListWarrenFilesError, RenameWarrenEntryError,
|
WarrenRmError, WarrenSaveError,
|
||||||
UploadWarrenFilesError,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
inbound::http::responses::ApiError,
|
inbound::http::responses::ApiError,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl From<CreateDirectoryError> for ApiError {
|
impl From<MkdirError> for ApiError {
|
||||||
fn from(value: CreateDirectoryError) -> Self {
|
fn from(value: MkdirError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
CreateDirectoryError::Exists => match value {
|
MkdirError::Exists => match value {
|
||||||
CreateDirectoryError::Exists => {
|
MkdirError::Exists => Self::BadRequest("The directory already exists".to_string()),
|
||||||
Self::BadRequest("The directory already exists".to_string())
|
MkdirError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
||||||
}
|
|
||||||
CreateDirectoryError::Unknown(error) => {
|
|
||||||
Self::InternalServerError(error.to_string())
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
CreateDirectoryError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
MkdirError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CreateWarrenDirectoryError> for ApiError {
|
impl From<WarrenMkdirError> for ApiError {
|
||||||
fn from(value: CreateWarrenDirectoryError) -> Self {
|
fn from(value: WarrenMkdirError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
CreateWarrenDirectoryError::FileSystem(fs) => fs.into(),
|
WarrenMkdirError::FileSystem(fs) => fs.into(),
|
||||||
CreateWarrenDirectoryError::FetchWarren(err) => err.into(),
|
WarrenMkdirError::FetchWarren(err) => err.into(),
|
||||||
CreateWarrenDirectoryError::Unknown(error) => {
|
WarrenMkdirError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
||||||
Self::InternalServerError(error.to_string())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DeleteDirectoryError> for ApiError {
|
impl From<RmError> for ApiError {
|
||||||
fn from(value: DeleteDirectoryError) -> Self {
|
fn from(value: RmError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
DeleteDirectoryError::NotFound => {
|
RmError::NotFound => Self::NotFound("The directory does not exist".to_string()),
|
||||||
Self::NotFound("The directory does not exist".to_string())
|
RmError::NotEmpty => Self::BadRequest("The directory is not empty".to_string()),
|
||||||
}
|
RmError::Unknown(e) => Self::InternalServerError(e.to_string()),
|
||||||
DeleteDirectoryError::NotEmpty => {
|
|
||||||
Self::BadRequest("The directory is not empty".to_string())
|
|
||||||
}
|
|
||||||
DeleteDirectoryError::Unknown(e) => Self::InternalServerError(e.to_string()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DeleteWarrenDirectoryError> for ApiError {
|
impl From<WarrenRmError> for ApiError {
|
||||||
fn from(value: DeleteWarrenDirectoryError) -> Self {
|
fn from(value: WarrenRmError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
DeleteWarrenDirectoryError::FileSystem(fs) => fs.into(),
|
WarrenRmError::FileSystem(fs) => fs.into(),
|
||||||
DeleteWarrenDirectoryError::FetchWarren(err) => err.into(),
|
WarrenRmError::FetchWarren(err) => err.into(),
|
||||||
DeleteWarrenDirectoryError::Unknown(error) => {
|
WarrenRmError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
||||||
Self::InternalServerError(error.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DeleteFileError> for ApiError {
|
|
||||||
fn from(value: DeleteFileError) -> Self {
|
|
||||||
Self::InternalServerError(value.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DeleteWarrenFileError> for ApiError {
|
|
||||||
fn from(value: DeleteWarrenFileError) -> Self {
|
|
||||||
match value {
|
|
||||||
DeleteWarrenFileError::FileSystem(fs) => fs.into(),
|
|
||||||
DeleteWarrenFileError::FetchWarren(err) => err.into(),
|
|
||||||
DeleteWarrenFileError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,23 +65,23 @@ impl From<FetchWarrenError> for ApiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ListFilesError> for ApiError {
|
impl From<LsError> for ApiError {
|
||||||
fn from(value: ListFilesError) -> Self {
|
fn from(value: LsError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ListFilesError::NotFound(_) => {
|
LsError::NotFound(_) => {
|
||||||
Self::NotFound("Could not find the requested directory".to_string())
|
Self::NotFound("Could not find the requested directory".to_string())
|
||||||
}
|
}
|
||||||
ListFilesError::Unknown(e) => Self::InternalServerError(e.to_string()),
|
LsError::Unknown(e) => Self::InternalServerError(e.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ListWarrenFilesError> for ApiError {
|
impl From<WarrenLsError> for ApiError {
|
||||||
fn from(value: ListWarrenFilesError) -> Self {
|
fn from(value: WarrenLsError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ListWarrenFilesError::FileSystem(fs_error) => fs_error.into(),
|
WarrenLsError::FileSystem(fs_error) => fs_error.into(),
|
||||||
ListWarrenFilesError::FetchWarren(err) => err.into(),
|
WarrenLsError::FetchWarren(err) => err.into(),
|
||||||
ListWarrenFilesError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
WarrenLsError::Unknown(error) => Self::InternalServerError(error.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,14 +92,14 @@ impl From<FetchWarrensError> for ApiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RenameWarrenEntryError> for ApiError {
|
impl From<WarrenMvError> for ApiError {
|
||||||
fn from(value: RenameWarrenEntryError) -> Self {
|
fn from(value: WarrenMvError) -> Self {
|
||||||
Self::InternalServerError(value.to_string())
|
Self::InternalServerError(value.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<UploadWarrenFilesError> for ApiError {
|
impl From<WarrenSaveError> for ApiError {
|
||||||
fn from(value: UploadWarrenFilesError) -> Self {
|
fn from(value: WarrenSaveError) -> Self {
|
||||||
Self::InternalServerError(value.to_string())
|
Self::InternalServerError(value.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
mod create_warren_directory;
|
|
||||||
mod delete_warren_directory;
|
|
||||||
mod delete_warren_file;
|
|
||||||
mod fetch_file;
|
|
||||||
mod fetch_warren;
|
mod fetch_warren;
|
||||||
mod list_warren_files;
|
|
||||||
mod list_warrens;
|
mod list_warrens;
|
||||||
mod rename_warren_entry;
|
|
||||||
mod upload_warren_files;
|
mod upload_warren_files;
|
||||||
|
mod warren_cat;
|
||||||
|
mod warren_ls;
|
||||||
|
mod warren_mkdir;
|
||||||
|
mod warren_move;
|
||||||
|
mod warren_rm;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
Router,
|
||||||
extract::DefaultBodyLimit,
|
extract::DefaultBodyLimit,
|
||||||
routing::{delete, get, patch, post},
|
routing::{get, post},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -20,30 +19,28 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use fetch_warren::fetch_warren;
|
use fetch_warren::fetch_warren;
|
||||||
use list_warren_files::list_warren_files;
|
|
||||||
use list_warrens::list_warrens;
|
use list_warrens::list_warrens;
|
||||||
|
use warren_ls::list_warren_files;
|
||||||
|
|
||||||
use create_warren_directory::create_warren_directory;
|
use warren_mkdir::create_warren_directory;
|
||||||
use delete_warren_directory::delete_warren_directory;
|
use warren_rm::warren_rm;
|
||||||
|
|
||||||
use delete_warren_file::delete_warren_file;
|
use upload_warren_files::warren_save;
|
||||||
use fetch_file::fetch_file;
|
use warren_cat::fetch_file;
|
||||||
use rename_warren_entry::rename_warren_entry;
|
use warren_move::warren_move;
|
||||||
use upload_warren_files::upload_warren_files;
|
|
||||||
|
|
||||||
pub fn routes<WS: WarrenService, AS: AuthService>() -> Router<AppState<WS, AS>> {
|
pub fn routes<WS: WarrenService, AS: AuthService>() -> Router<AppState<WS, AS>> {
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/", get(list_warrens))
|
.route("/", get(list_warrens))
|
||||||
.route("/", post(fetch_warren))
|
.route("/", post(fetch_warren))
|
||||||
.route("/files/fetch", get(fetch_file))
|
.route("/files/cat", get(fetch_file))
|
||||||
.route("/files", post(list_warren_files))
|
.route("/files/ls", post(list_warren_files))
|
||||||
.route("/files/directory", post(create_warren_directory))
|
.route("/files/mkdir", post(create_warren_directory))
|
||||||
.route("/files/directory", delete(delete_warren_directory))
|
.route("/files/rm", post(warren_rm))
|
||||||
.route(
|
.route(
|
||||||
"/files/upload",
|
"/files/save",
|
||||||
// 1073741824 bytes = 1GB
|
// 1073741824 bytes = 1GB
|
||||||
post(upload_warren_files).route_layer(DefaultBodyLimit::max(1073741824)),
|
post(warren_save).route_layer(DefaultBodyLimit::max(1073741824)),
|
||||||
)
|
)
|
||||||
.route("/files/file", delete(delete_warren_file))
|
.route("/files/mv", post(warren_move))
|
||||||
.route("/files/rename", patch(rename_warren_entry))
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
use axum::{Json, extract::State, http::StatusCode};
|
|
||||||
use serde::Deserialize;
|
|
||||||
use thiserror::Error;
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
domain::warren::{
|
|
||||||
models::{
|
|
||||||
auth_session::AuthRequest,
|
|
||||||
file::{
|
|
||||||
AbsoluteFilePath, AbsoluteFilePathError, FileName, FileNameError, FilePath,
|
|
||||||
FilePathError,
|
|
||||||
},
|
|
||||||
warren::RenameWarrenEntryRequest,
|
|
||||||
},
|
|
||||||
ports::{AuthService, WarrenService},
|
|
||||||
},
|
|
||||||
inbound::http::{
|
|
||||||
AppState,
|
|
||||||
handlers::extractors::SessionIdHeader,
|
|
||||||
responses::{ApiError, ApiSuccess},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct RenameWarrenEntryHttpRequestBody {
|
|
||||||
warren_id: Uuid,
|
|
||||||
path: String,
|
|
||||||
new_name: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
|
||||||
pub enum ParseRenameWarrenEntryHttpRequestError {
|
|
||||||
#[error(transparent)]
|
|
||||||
FilePath(#[from] FilePathError),
|
|
||||||
#[error(transparent)]
|
|
||||||
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
|
||||||
#[error(transparent)]
|
|
||||||
FileName(#[from] FileNameError),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RenameWarrenEntryHttpRequestBody {
|
|
||||||
fn try_into_domain(
|
|
||||||
self,
|
|
||||||
) -> Result<RenameWarrenEntryRequest, ParseRenameWarrenEntryHttpRequestError> {
|
|
||||||
let path: AbsoluteFilePath = FilePath::new(&self.path)?.try_into()?;
|
|
||||||
let new_name = FileName::new(&self.new_name)?;
|
|
||||||
|
|
||||||
Ok(RenameWarrenEntryRequest::new(
|
|
||||||
self.warren_id,
|
|
||||||
path,
|
|
||||||
new_name,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ParseRenameWarrenEntryHttpRequestError> for ApiError {
|
|
||||||
fn from(value: ParseRenameWarrenEntryHttpRequestError) -> Self {
|
|
||||||
match value {
|
|
||||||
ParseRenameWarrenEntryHttpRequestError::FilePath(err) => match err {
|
|
||||||
FilePathError::InvalidPath => {
|
|
||||||
ApiError::BadRequest("The file path must be valid".to_string())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ParseRenameWarrenEntryHttpRequestError::AbsoluteFilePath(err) => match err {
|
|
||||||
AbsoluteFilePathError::NotAbsolute => {
|
|
||||||
ApiError::BadRequest("The file path must be absolute".to_string())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ParseRenameWarrenEntryHttpRequestError::FileName(err) => match err {
|
|
||||||
FileNameError::Slash => {
|
|
||||||
ApiError::BadRequest("The new name must not include a slash".to_string())
|
|
||||||
}
|
|
||||||
FileNameError::Empty => {
|
|
||||||
ApiError::BadRequest("The new name must not be empty".to_string())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn rename_warren_entry<WS: WarrenService, AS: AuthService>(
|
|
||||||
State(state): State<AppState<WS, AS>>,
|
|
||||||
SessionIdHeader(session): SessionIdHeader,
|
|
||||||
Json(request): Json<RenameWarrenEntryHttpRequestBody>,
|
|
||||||
) -> Result<ApiSuccess<()>, ApiError> {
|
|
||||||
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
|
||||||
|
|
||||||
state
|
|
||||||
.auth_service
|
|
||||||
.rename_warren_entry(domain_request, state.warren_service.as_ref())
|
|
||||||
.await
|
|
||||||
.map(|_| ApiSuccess::new(StatusCode::OK, ()))
|
|
||||||
.map_err(ApiError::from)
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,21 @@
|
|||||||
use axum::{body::Bytes, extract::State, http::StatusCode};
|
use std::str::FromStr as _;
|
||||||
use axum_typed_multipart::{FieldData, TryFromMultipart, TypedMultipart};
|
|
||||||
|
use anyhow::{anyhow, bail};
|
||||||
|
use axum::{extract::State, http::StatusCode};
|
||||||
|
use axum_extra::extract::Multipart;
|
||||||
|
use bytes::Bytes;
|
||||||
|
use futures_util::{StreamExt as _, TryStreamExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
domain::warren::{
|
domain::warren::{
|
||||||
models::{
|
models::{
|
||||||
auth_session::AuthRequest,
|
auth_session::AuthRequest,
|
||||||
file::{AbsoluteFilePathError, FileName, FileNameError, FilePath, FilePathError},
|
file::{
|
||||||
warren::{UploadFile, UploadFileList, UploadFileListError, UploadWarrenFilesRequest},
|
AbsoluteFilePath, AbsoluteFilePathError, FileName, FileNameError, FilePath,
|
||||||
|
FilePathError, SaveRequest,
|
||||||
|
},
|
||||||
|
warren::{UploadFile, UploadFileStream, WarrenSaveRequest},
|
||||||
},
|
},
|
||||||
ports::{AuthService, WarrenService},
|
ports::{AuthService, WarrenService},
|
||||||
},
|
},
|
||||||
@@ -19,70 +26,94 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, TryFromMultipart)]
|
#[derive(Debug, Error)]
|
||||||
#[try_from_multipart(rename_all = "camelCase")]
|
enum ParseWarrenSaveHttpRequestError {
|
||||||
pub struct UploadWarrenFilesHttpRequestBody {
|
#[error(transparent)]
|
||||||
warren_id: Uuid,
|
Multipart(#[from] axum_extra::extract::multipart::MultipartError),
|
||||||
path: String,
|
#[error("The form was submitted with a missing or invalid field")]
|
||||||
files: Vec<FieldData<Bytes>>,
|
Field,
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
|
||||||
enum ParseUploadWarrenFilesHttpRequestError {
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FileName(#[from] FileNameError),
|
FileName(#[from] FileNameError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FilePath(#[from] FilePathError),
|
FilePath(#[from] FilePathError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FileList(#[from] UploadFileListError),
|
|
||||||
#[error(transparent)]
|
|
||||||
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UploadWarrenFilesHttpRequestBody {
|
async fn try_into_domain<'s>(
|
||||||
fn try_into_domain(
|
mut multipart: Multipart,
|
||||||
self,
|
) -> Result<WarrenSaveRequest<'s>, ParseWarrenSaveHttpRequestError> {
|
||||||
) -> Result<UploadWarrenFilesRequest, ParseUploadWarrenFilesHttpRequestError> {
|
let warren_id = {
|
||||||
let path = FilePath::new(&self.path)?;
|
let field = multipart
|
||||||
|
.next_field()
|
||||||
let mut files = Vec::with_capacity(self.files.len());
|
.await?
|
||||||
|
.ok_or(ParseWarrenSaveHttpRequestError::Field)?;
|
||||||
for file in self.files {
|
let name = field.name().ok_or(ParseWarrenSaveHttpRequestError::Field)?;
|
||||||
let raw_file_name = file.metadata.file_name.ok_or(FileNameError::Empty)?;
|
if name != "warrenId" {
|
||||||
let file_name = FileName::new(&raw_file_name)?;
|
return Err(ParseWarrenSaveHttpRequestError::Field);
|
||||||
let data = file.contents.to_vec().into_boxed_slice();
|
|
||||||
files.push(UploadFile::new(file_name, data));
|
|
||||||
}
|
}
|
||||||
|
uuid::Uuid::from_str(&field.text().await?)
|
||||||
|
.map_err(|_| ParseWarrenSaveHttpRequestError::Field)?
|
||||||
|
};
|
||||||
|
let path: AbsoluteFilePath = {
|
||||||
|
let field = multipart
|
||||||
|
.next_field()
|
||||||
|
.await?
|
||||||
|
.ok_or(ParseWarrenSaveHttpRequestError::Field)?;
|
||||||
|
let name = field.name().ok_or(ParseWarrenSaveHttpRequestError::Field)?;
|
||||||
|
if name != "path" {
|
||||||
|
return Err(ParseWarrenSaveHttpRequestError::Field);
|
||||||
|
}
|
||||||
|
FilePath::new(&field.text().await?)?.try_into()?
|
||||||
|
};
|
||||||
|
|
||||||
let files = UploadFileList::new(files)?;
|
let stream = Box::pin(multipart.into_stream().map(|r| {
|
||||||
|
let field = match r {
|
||||||
|
Ok(field) => field,
|
||||||
|
Err(e) => return Err(anyhow!("Failed to get field: {e:?}")),
|
||||||
|
};
|
||||||
|
|
||||||
Ok(UploadWarrenFilesRequest::new(
|
if field.name().is_none_or(|name| name != "files") {
|
||||||
self.warren_id,
|
bail!("Invalid field name");
|
||||||
path.try_into()?,
|
};
|
||||||
files,
|
|
||||||
))
|
let Some(Ok(file_name)) = field.file_name().map(FileName::new) else {
|
||||||
}
|
bail!("Invalid file name");
|
||||||
|
};
|
||||||
|
|
||||||
|
let file = UploadFile::new(
|
||||||
|
file_name,
|
||||||
|
field
|
||||||
|
.into_stream()
|
||||||
|
.map_err(tokio::io::Error::other)
|
||||||
|
.map_ok(|bytes| Bytes::from(bytes)),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(file)
|
||||||
|
}));
|
||||||
|
|
||||||
|
let stream = UploadFileStream::new(stream);
|
||||||
|
|
||||||
|
Ok(WarrenSaveRequest::new(
|
||||||
|
warren_id,
|
||||||
|
SaveRequest::new(path, stream),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseUploadWarrenFilesHttpRequestError> for ApiError {
|
impl From<ParseWarrenSaveHttpRequestError> for ApiError {
|
||||||
fn from(value: ParseUploadWarrenFilesHttpRequestError) -> Self {
|
fn from(value: ParseWarrenSaveHttpRequestError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ParseUploadWarrenFilesHttpRequestError::FilePath(err) => match err {
|
ParseWarrenSaveHttpRequestError::FilePath(err) => match err {
|
||||||
FilePathError::InvalidPath => {
|
FilePathError::InvalidPath => {
|
||||||
ApiError::BadRequest("The file path must be valid".to_string())
|
ApiError::BadRequest("The file path must be valid".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ParseUploadWarrenFilesHttpRequestError::AbsoluteFilePath(err) => match err {
|
ParseWarrenSaveHttpRequestError::AbsoluteFilePath(err) => match err {
|
||||||
AbsoluteFilePathError::NotAbsolute => {
|
AbsoluteFilePathError::NotAbsolute => {
|
||||||
ApiError::BadRequest("The file path must be absolute".to_string())
|
ApiError::BadRequest("The file path must be absolute".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ParseUploadWarrenFilesHttpRequestError::FileList(err) => match err {
|
ParseWarrenSaveHttpRequestError::FileName(err) => match err {
|
||||||
UploadFileListError::Empty => {
|
|
||||||
ApiError::BadRequest("There has to be at least 1 file present".to_string())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ParseUploadWarrenFilesHttpRequestError::FileName(err) => match err {
|
|
||||||
FileNameError::Slash => {
|
FileNameError::Slash => {
|
||||||
ApiError::BadRequest("A file's name contained an invalid character".to_string())
|
ApiError::BadRequest("A file's name contained an invalid character".to_string())
|
||||||
}
|
}
|
||||||
@@ -90,20 +121,26 @@ impl From<ParseUploadWarrenFilesHttpRequestError> for ApiError {
|
|||||||
ApiError::BadRequest("File names must not be empty".to_string())
|
ApiError::BadRequest("File names must not be empty".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ParseWarrenSaveHttpRequestError::Field => ApiError::BadRequest(
|
||||||
|
"The form was submitted with a missing or invalid field".to_string(),
|
||||||
|
),
|
||||||
|
ParseWarrenSaveHttpRequestError::Multipart(e) => {
|
||||||
|
ApiError::InternalServerError(e.to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upload_warren_files<WS: WarrenService, AS: AuthService>(
|
pub async fn warren_save<WS: WarrenService, AS: AuthService>(
|
||||||
State(state): State<AppState<WS, AS>>,
|
State(state): State<AppState<WS, AS>>,
|
||||||
SessionIdHeader(session): SessionIdHeader,
|
SessionIdHeader(session): SessionIdHeader,
|
||||||
TypedMultipart(multipart): TypedMultipart<UploadWarrenFilesHttpRequestBody>,
|
multipart: Multipart,
|
||||||
) -> Result<ApiSuccess<()>, ApiError> {
|
) -> Result<ApiSuccess<()>, ApiError> {
|
||||||
let domain_request = AuthRequest::new(session, multipart.try_into_domain()?);
|
let domain_request = AuthRequest::new(session, try_into_domain(multipart).await?);
|
||||||
|
|
||||||
state
|
state
|
||||||
.auth_service
|
.auth_service
|
||||||
.upload_warren_files(domain_request, state.warren_service.as_ref())
|
.auth_warren_save(domain_request, state.warren_service.as_ref())
|
||||||
.await
|
.await
|
||||||
.map(|_| ApiSuccess::new(StatusCode::CREATED, ()))
|
.map(|_| ApiSuccess::new(StatusCode::CREATED, ()))
|
||||||
.map_err(ApiError::from)
|
.map_err(ApiError::from)
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ use crate::{
|
|||||||
domain::warren::{
|
domain::warren::{
|
||||||
models::{
|
models::{
|
||||||
auth_session::AuthRequest,
|
auth_session::AuthRequest,
|
||||||
file::{AbsoluteFilePathError, FilePath, FilePathError, FileStream},
|
file::{AbsoluteFilePathError, CatRequest, FilePath, FilePathError, FileStream},
|
||||||
warren::FetchWarrenFileRequest,
|
warren::WarrenCatRequest,
|
||||||
},
|
},
|
||||||
ports::{AuthService, WarrenService},
|
ports::{AuthService, WarrenService},
|
||||||
},
|
},
|
||||||
@@ -37,28 +37,28 @@ impl From<Vec<u8>> for FetchWarrenFileHttpResponseBody {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FetchWarrenFileHttpRequestBody {
|
pub(super) struct WarrenCatHttpRequestBody {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: String,
|
path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Clone, Error)]
|
||||||
pub enum ParseFetchWarrenFileHttpRequestError {
|
pub enum ParseWarrenCatHttpRequestError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FilePath(#[from] FilePathError),
|
FilePath(#[from] FilePathError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseFetchWarrenFileHttpRequestError> for ApiError {
|
impl From<ParseWarrenCatHttpRequestError> for ApiError {
|
||||||
fn from(value: ParseFetchWarrenFileHttpRequestError) -> Self {
|
fn from(value: ParseWarrenCatHttpRequestError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ParseFetchWarrenFileHttpRequestError::FilePath(err) => match err {
|
ParseWarrenCatHttpRequestError::FilePath(err) => match err {
|
||||||
FilePathError::InvalidPath => {
|
FilePathError::InvalidPath => {
|
||||||
ApiError::BadRequest("The file path must be valid".to_string())
|
ApiError::BadRequest("The file path must be valid".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ParseFetchWarrenFileHttpRequestError::AbsoluteFilePath(err) => match err {
|
ParseWarrenCatHttpRequestError::AbsoluteFilePath(err) => match err {
|
||||||
AbsoluteFilePathError::NotAbsolute => {
|
AbsoluteFilePathError::NotAbsolute => {
|
||||||
ApiError::BadRequest("The file path must be absolute".to_string())
|
ApiError::BadRequest("The file path must be absolute".to_string())
|
||||||
}
|
}
|
||||||
@@ -67,13 +67,11 @@ impl From<ParseFetchWarrenFileHttpRequestError> for ApiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FetchWarrenFileHttpRequestBody {
|
impl WarrenCatHttpRequestBody {
|
||||||
fn try_into_domain(
|
fn try_into_domain(self) -> Result<WarrenCatRequest, ParseWarrenCatHttpRequestError> {
|
||||||
self,
|
|
||||||
) -> Result<FetchWarrenFileRequest, ParseFetchWarrenFileHttpRequestError> {
|
|
||||||
let path = FilePath::new(&self.path)?.try_into()?;
|
let path = FilePath::new(&self.path)?.try_into()?;
|
||||||
|
|
||||||
Ok(FetchWarrenFileRequest::new(self.warren_id, path))
|
Ok(WarrenCatRequest::new(self.warren_id, CatRequest::new(path)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,16 +84,13 @@ impl From<FileStream> for Body {
|
|||||||
pub async fn fetch_file<WS: WarrenService, AS: AuthService>(
|
pub async fn fetch_file<WS: WarrenService, AS: AuthService>(
|
||||||
State(state): State<AppState<WS, AS>>,
|
State(state): State<AppState<WS, AS>>,
|
||||||
SessionIdHeader(session): SessionIdHeader,
|
SessionIdHeader(session): SessionIdHeader,
|
||||||
Query(request): Query<FetchWarrenFileHttpRequestBody>,
|
Query(request): Query<WarrenCatHttpRequestBody>,
|
||||||
) -> Result<Body, ApiError> {
|
) -> Result<Body, ApiError> {
|
||||||
let domain_request = request.try_into_domain()?;
|
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
||||||
|
|
||||||
state
|
state
|
||||||
.auth_service
|
.auth_service
|
||||||
.fetch_warren_file(
|
.auth_warren_cat(domain_request, state.warren_service.as_ref())
|
||||||
AuthRequest::new(session, domain_request),
|
|
||||||
state.warren_service.as_ref(),
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map(|contents| contents.into())
|
.map(|contents| contents.into())
|
||||||
.map_err(ApiError::from)
|
.map_err(ApiError::from)
|
||||||
@@ -7,8 +7,11 @@ use crate::{
|
|||||||
domain::warren::{
|
domain::warren::{
|
||||||
models::{
|
models::{
|
||||||
auth_session::AuthRequest,
|
auth_session::AuthRequest,
|
||||||
file::{AbsoluteFilePathError, File, FileMimeType, FilePath, FilePathError, FileType},
|
file::{
|
||||||
warren::ListWarrenFilesRequest,
|
AbsoluteFilePathError, File, FileMimeType, FilePath, FilePathError, FileType,
|
||||||
|
LsRequest,
|
||||||
|
},
|
||||||
|
warren::WarrenLsRequest,
|
||||||
},
|
},
|
||||||
ports::{AuthService, WarrenService},
|
ports::{AuthService, WarrenService},
|
||||||
},
|
},
|
||||||
@@ -20,7 +23,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Clone, Error)]
|
||||||
pub enum ParseListWarrenHttpRequestError {
|
pub enum ParseWarrenLsHttpRequestError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FilePath(#[from] FilePathError),
|
FilePath(#[from] FilePathError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
@@ -29,31 +32,28 @@ pub enum ParseListWarrenHttpRequestError {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ListWarrenFilesHttpRequestBody {
|
pub(super) struct WarrenLsHttpRequestBody {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: String,
|
path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListWarrenFilesHttpRequestBody {
|
impl WarrenLsHttpRequestBody {
|
||||||
fn try_into_domain(self) -> Result<ListWarrenFilesRequest, ParseListWarrenHttpRequestError> {
|
fn try_into_domain(self) -> Result<WarrenLsRequest, ParseWarrenLsHttpRequestError> {
|
||||||
let path = FilePath::new(&self.path)?;
|
let path = FilePath::new(&self.path)?.try_into()?;
|
||||||
|
|
||||||
Ok(ListWarrenFilesRequest::new(
|
Ok(WarrenLsRequest::new(self.warren_id, LsRequest::new(path)))
|
||||||
self.warren_id,
|
|
||||||
path.try_into()?,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseListWarrenHttpRequestError> for ApiError {
|
impl From<ParseWarrenLsHttpRequestError> for ApiError {
|
||||||
fn from(value: ParseListWarrenHttpRequestError) -> Self {
|
fn from(value: ParseWarrenLsHttpRequestError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ParseListWarrenHttpRequestError::FilePath(err) => match err {
|
ParseWarrenLsHttpRequestError::FilePath(err) => match err {
|
||||||
FilePathError::InvalidPath => {
|
FilePathError::InvalidPath => {
|
||||||
ApiError::BadRequest("The file path must be valid".to_string())
|
ApiError::BadRequest("The file path must be valid".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ParseListWarrenHttpRequestError::AbsoluteFilePath(err) => match err {
|
ParseWarrenLsHttpRequestError::AbsoluteFilePath(err) => match err {
|
||||||
AbsoluteFilePathError::NotAbsolute => {
|
AbsoluteFilePathError::NotAbsolute => {
|
||||||
ApiError::BadRequest("The file path must be absolute".to_string())
|
ApiError::BadRequest("The file path must be absolute".to_string())
|
||||||
}
|
}
|
||||||
@@ -99,13 +99,13 @@ impl From<&Vec<File>> for ListWarrenFilesResponseData {
|
|||||||
pub async fn list_warren_files<WS: WarrenService, AS: AuthService>(
|
pub async fn list_warren_files<WS: WarrenService, AS: AuthService>(
|
||||||
State(state): State<AppState<WS, AS>>,
|
State(state): State<AppState<WS, AS>>,
|
||||||
SessionIdHeader(session): SessionIdHeader,
|
SessionIdHeader(session): SessionIdHeader,
|
||||||
Json(request): Json<ListWarrenFilesHttpRequestBody>,
|
Json(request): Json<WarrenLsHttpRequestBody>,
|
||||||
) -> Result<ApiSuccess<ListWarrenFilesResponseData>, ApiError> {
|
) -> Result<ApiSuccess<ListWarrenFilesResponseData>, ApiError> {
|
||||||
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
||||||
|
|
||||||
state
|
state
|
||||||
.auth_service
|
.auth_service
|
||||||
.list_warren_files(domain_request, state.warren_service.as_ref())
|
.auth_warren_ls(domain_request, state.warren_service.as_ref())
|
||||||
.await
|
.await
|
||||||
.map(|response| ApiSuccess::new(StatusCode::OK, response.files().into()))
|
.map(|response| ApiSuccess::new(StatusCode::OK, response.files().into()))
|
||||||
.map_err(ApiError::from)
|
.map_err(ApiError::from)
|
||||||
@@ -7,8 +7,8 @@ use crate::{
|
|||||||
domain::warren::{
|
domain::warren::{
|
||||||
models::{
|
models::{
|
||||||
auth_session::AuthRequest,
|
auth_session::AuthRequest,
|
||||||
file::{AbsoluteFilePathError, FilePath, FilePathError},
|
file::{AbsoluteFilePathError, FilePath, FilePathError, MkdirRequest},
|
||||||
warren::CreateWarrenDirectoryRequest,
|
warren::WarrenMkdirRequest,
|
||||||
},
|
},
|
||||||
ports::{AuthService, WarrenService},
|
ports::{AuthService, WarrenService},
|
||||||
},
|
},
|
||||||
@@ -21,28 +21,28 @@ use crate::{
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CreateWarrenDirectoryHttpRequestBody {
|
pub(super) struct WarrenMkdirHttpRequestBody {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: String,
|
path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Clone, Error)]
|
||||||
pub enum ParseCreateWarrenDirectoryHttpRequestError {
|
pub(super) enum ParseWarrenMkdirHttpRequestError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FilePath(#[from] FilePathError),
|
FilePath(#[from] FilePathError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseCreateWarrenDirectoryHttpRequestError> for ApiError {
|
impl From<ParseWarrenMkdirHttpRequestError> for ApiError {
|
||||||
fn from(value: ParseCreateWarrenDirectoryHttpRequestError) -> Self {
|
fn from(value: ParseWarrenMkdirHttpRequestError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ParseCreateWarrenDirectoryHttpRequestError::FilePath(err) => match err {
|
ParseWarrenMkdirHttpRequestError::FilePath(err) => match err {
|
||||||
FilePathError::InvalidPath => {
|
FilePathError::InvalidPath => {
|
||||||
ApiError::BadRequest("The file path must be valid".to_string())
|
ApiError::BadRequest("The file path must be valid".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ParseCreateWarrenDirectoryHttpRequestError::AbsoluteFilePath(err) => match err {
|
ParseWarrenMkdirHttpRequestError::AbsoluteFilePath(err) => match err {
|
||||||
AbsoluteFilePathError::NotAbsolute => {
|
AbsoluteFilePathError::NotAbsolute => {
|
||||||
ApiError::BadRequest("The file path must be absolute".to_string())
|
ApiError::BadRequest("The file path must be absolute".to_string())
|
||||||
}
|
}
|
||||||
@@ -51,15 +51,13 @@ impl From<ParseCreateWarrenDirectoryHttpRequestError> for ApiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateWarrenDirectoryHttpRequestBody {
|
impl WarrenMkdirHttpRequestBody {
|
||||||
fn try_into_domain(
|
fn try_into_domain(self) -> Result<WarrenMkdirRequest, ParseWarrenMkdirHttpRequestError> {
|
||||||
self,
|
|
||||||
) -> Result<CreateWarrenDirectoryRequest, ParseCreateWarrenDirectoryHttpRequestError> {
|
|
||||||
let path = FilePath::new(&self.path)?;
|
let path = FilePath::new(&self.path)?;
|
||||||
|
|
||||||
Ok(CreateWarrenDirectoryRequest::new(
|
Ok(WarrenMkdirRequest::new(
|
||||||
self.warren_id,
|
self.warren_id,
|
||||||
path.try_into()?,
|
MkdirRequest::new(path.try_into()?),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,13 +65,13 @@ impl CreateWarrenDirectoryHttpRequestBody {
|
|||||||
pub async fn create_warren_directory<WS: WarrenService, AS: AuthService>(
|
pub async fn create_warren_directory<WS: WarrenService, AS: AuthService>(
|
||||||
State(state): State<AppState<WS, AS>>,
|
State(state): State<AppState<WS, AS>>,
|
||||||
SessionIdHeader(session): SessionIdHeader,
|
SessionIdHeader(session): SessionIdHeader,
|
||||||
Json(request): Json<CreateWarrenDirectoryHttpRequestBody>,
|
Json(request): Json<WarrenMkdirHttpRequestBody>,
|
||||||
) -> Result<ApiSuccess<()>, ApiError> {
|
) -> Result<ApiSuccess<()>, ApiError> {
|
||||||
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
||||||
|
|
||||||
state
|
state
|
||||||
.auth_service
|
.auth_service
|
||||||
.create_warren_directory(domain_request, state.warren_service.as_ref())
|
.auth_warren_mkdir(domain_request, state.warren_service.as_ref())
|
||||||
.await
|
.await
|
||||||
.map(|_| ApiSuccess::new(StatusCode::CREATED, ()))
|
.map(|_| ApiSuccess::new(StatusCode::CREATED, ()))
|
||||||
.map_err(ApiError::from)
|
.map_err(ApiError::from)
|
||||||
@@ -7,8 +7,8 @@ use crate::{
|
|||||||
domain::warren::{
|
domain::warren::{
|
||||||
models::{
|
models::{
|
||||||
auth_session::AuthRequest,
|
auth_session::AuthRequest,
|
||||||
file::{AbsoluteFilePathError, FilePath, FilePathError},
|
file::{AbsoluteFilePath, AbsoluteFilePathError, FilePath, FilePathError, MvRequest},
|
||||||
warren::DeleteWarrenDirectoryRequest,
|
warren::WarrenMvRequest,
|
||||||
},
|
},
|
||||||
ports::{AuthService, WarrenService},
|
ports::{AuthService, WarrenService},
|
||||||
},
|
},
|
||||||
@@ -21,29 +21,41 @@ use crate::{
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct DeleteWarrenDirectoryHttpRequestBody {
|
pub struct RenameWarrenEntryHttpRequestBody {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: String,
|
path: String,
|
||||||
force: bool,
|
target_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Clone, Error)]
|
||||||
pub enum ParseDeleteWarrenDirectoryHttpRequestError {
|
pub enum ParseWarrenMvHttpRequestError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FilePath(#[from] FilePathError),
|
FilePath(#[from] FilePathError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseDeleteWarrenDirectoryHttpRequestError> for ApiError {
|
impl RenameWarrenEntryHttpRequestBody {
|
||||||
fn from(value: ParseDeleteWarrenDirectoryHttpRequestError) -> Self {
|
fn try_into_domain(self) -> Result<WarrenMvRequest, ParseWarrenMvHttpRequestError> {
|
||||||
|
let path: AbsoluteFilePath = FilePath::new(&self.path)?.try_into()?;
|
||||||
|
let target_path: AbsoluteFilePath = FilePath::new(&self.target_path)?.try_into()?;
|
||||||
|
|
||||||
|
Ok(WarrenMvRequest::new(
|
||||||
|
self.warren_id,
|
||||||
|
MvRequest::new(path, target_path),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ParseWarrenMvHttpRequestError> for ApiError {
|
||||||
|
fn from(value: ParseWarrenMvHttpRequestError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ParseDeleteWarrenDirectoryHttpRequestError::FilePath(err) => match err {
|
ParseWarrenMvHttpRequestError::FilePath(err) => match err {
|
||||||
FilePathError::InvalidPath => {
|
FilePathError::InvalidPath => {
|
||||||
ApiError::BadRequest("The file path must be valid".to_string())
|
ApiError::BadRequest("The file path must be valid".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ParseDeleteWarrenDirectoryHttpRequestError::AbsoluteFilePath(err) => match err {
|
ParseWarrenMvHttpRequestError::AbsoluteFilePath(err) => match err {
|
||||||
AbsoluteFilePathError::NotAbsolute => {
|
AbsoluteFilePathError::NotAbsolute => {
|
||||||
ApiError::BadRequest("The file path must be absolute".to_string())
|
ApiError::BadRequest("The file path must be absolute".to_string())
|
||||||
}
|
}
|
||||||
@@ -52,31 +64,17 @@ impl From<ParseDeleteWarrenDirectoryHttpRequestError> for ApiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeleteWarrenDirectoryHttpRequestBody {
|
pub async fn warren_move<WS: WarrenService, AS: AuthService>(
|
||||||
fn try_into_domain(
|
|
||||||
self,
|
|
||||||
) -> Result<DeleteWarrenDirectoryRequest, ParseDeleteWarrenDirectoryHttpRequestError> {
|
|
||||||
let path = FilePath::new(&self.path)?;
|
|
||||||
|
|
||||||
Ok(DeleteWarrenDirectoryRequest::new(
|
|
||||||
self.warren_id,
|
|
||||||
path.try_into()?,
|
|
||||||
self.force,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn delete_warren_directory<WS: WarrenService, AS: AuthService>(
|
|
||||||
State(state): State<AppState<WS, AS>>,
|
State(state): State<AppState<WS, AS>>,
|
||||||
SessionIdHeader(session): SessionIdHeader,
|
SessionIdHeader(session): SessionIdHeader,
|
||||||
Json(request): Json<DeleteWarrenDirectoryHttpRequestBody>,
|
Json(request): Json<RenameWarrenEntryHttpRequestBody>,
|
||||||
) -> Result<ApiSuccess<()>, ApiError> {
|
) -> Result<ApiSuccess<()>, ApiError> {
|
||||||
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
||||||
|
|
||||||
state
|
state
|
||||||
.auth_service
|
.auth_service
|
||||||
.delete_warren_directory(domain_request, state.warren_service.as_ref())
|
.auth_warren_mv(domain_request, state.warren_service.as_ref())
|
||||||
.await
|
.await
|
||||||
.map(|_| ApiSuccess::new(StatusCode::CREATED, ()))
|
.map(|_| ApiSuccess::new(StatusCode::OK, ()))
|
||||||
.map_err(ApiError::from)
|
.map_err(ApiError::from)
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,8 @@ use crate::{
|
|||||||
domain::warren::{
|
domain::warren::{
|
||||||
models::{
|
models::{
|
||||||
auth_session::AuthRequest,
|
auth_session::AuthRequest,
|
||||||
file::{AbsoluteFilePathError, FilePath, FilePathError},
|
file::{AbsoluteFilePathError, FilePath, FilePathError, RmRequest},
|
||||||
warren::DeleteWarrenFileRequest,
|
warren::WarrenRmRequest,
|
||||||
},
|
},
|
||||||
ports::{AuthService, WarrenService},
|
ports::{AuthService, WarrenService},
|
||||||
},
|
},
|
||||||
@@ -21,28 +21,29 @@ use crate::{
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct DeleteWarrenFileHttpRequestBody {
|
pub(super) struct WarrenRmHttpRequestBody {
|
||||||
warren_id: Uuid,
|
warren_id: Uuid,
|
||||||
path: String,
|
path: String,
|
||||||
|
force: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Clone, Error)]
|
||||||
pub enum ParseDeleteWarrenFileHttpRequestError {
|
pub(super) enum ParseWarrenRmHttpRequestError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FilePath(#[from] FilePathError),
|
FilePath(#[from] FilePathError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
AbsoluteFilePath(#[from] AbsoluteFilePathError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseDeleteWarrenFileHttpRequestError> for ApiError {
|
impl From<ParseWarrenRmHttpRequestError> for ApiError {
|
||||||
fn from(value: ParseDeleteWarrenFileHttpRequestError) -> Self {
|
fn from(value: ParseWarrenRmHttpRequestError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ParseDeleteWarrenFileHttpRequestError::FilePath(err) => match err {
|
ParseWarrenRmHttpRequestError::FilePath(err) => match err {
|
||||||
FilePathError::InvalidPath => {
|
FilePathError::InvalidPath => {
|
||||||
ApiError::BadRequest("The file path must be valid".to_string())
|
ApiError::BadRequest("The file path must be valid".to_string())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ParseDeleteWarrenFileHttpRequestError::AbsoluteFilePath(err) => match err {
|
ParseWarrenRmHttpRequestError::AbsoluteFilePath(err) => match err {
|
||||||
AbsoluteFilePathError::NotAbsolute => {
|
AbsoluteFilePathError::NotAbsolute => {
|
||||||
ApiError::BadRequest("The file path must be absolute".to_string())
|
ApiError::BadRequest("The file path must be absolute".to_string())
|
||||||
}
|
}
|
||||||
@@ -51,29 +52,27 @@ impl From<ParseDeleteWarrenFileHttpRequestError> for ApiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeleteWarrenFileHttpRequestBody {
|
impl WarrenRmHttpRequestBody {
|
||||||
fn try_into_domain(
|
fn try_into_domain(self) -> Result<WarrenRmRequest, ParseWarrenRmHttpRequestError> {
|
||||||
self,
|
|
||||||
) -> Result<DeleteWarrenFileRequest, ParseDeleteWarrenFileHttpRequestError> {
|
|
||||||
let path = FilePath::new(&self.path)?;
|
let path = FilePath::new(&self.path)?;
|
||||||
|
|
||||||
Ok(DeleteWarrenFileRequest::new(
|
Ok(WarrenRmRequest::new(
|
||||||
self.warren_id,
|
self.warren_id,
|
||||||
path.try_into()?,
|
RmRequest::new(path.try_into()?, self.force),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_warren_file<WS: WarrenService, AS: AuthService>(
|
pub async fn warren_rm<WS: WarrenService, AS: AuthService>(
|
||||||
State(state): State<AppState<WS, AS>>,
|
State(state): State<AppState<WS, AS>>,
|
||||||
SessionIdHeader(session): SessionIdHeader,
|
SessionIdHeader(session): SessionIdHeader,
|
||||||
Json(request): Json<DeleteWarrenFileHttpRequestBody>,
|
Json(request): Json<WarrenRmHttpRequestBody>,
|
||||||
) -> Result<ApiSuccess<()>, ApiError> {
|
) -> Result<ApiSuccess<()>, ApiError> {
|
||||||
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
let domain_request = AuthRequest::new(session, request.try_into_domain()?);
|
||||||
|
|
||||||
state
|
state
|
||||||
.auth_service
|
.auth_service
|
||||||
.delete_warren_file(domain_request, state.warren_service.as_ref())
|
.auth_warren_rm(domain_request, state.warren_service.as_ref())
|
||||||
.await
|
.await
|
||||||
.map(|_| ApiSuccess::new(StatusCode::CREATED, ()))
|
.map(|_| ApiSuccess::new(StatusCode::CREATED, ()))
|
||||||
.map_err(ApiError::from)
|
.map_err(ApiError::from)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
|
|
||||||
use anyhow::{Context, anyhow, bail};
|
use anyhow::{Context, anyhow, bail};
|
||||||
|
use futures_util::TryStreamExt;
|
||||||
use rustix::fs::statx;
|
use rustix::fs::statx;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
fs,
|
fs,
|
||||||
@@ -11,12 +12,14 @@ use tokio_util::io::ReaderStream;
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
domain::warren::{
|
domain::warren::{
|
||||||
models::file::{
|
models::{
|
||||||
AbsoluteFilePath, CreateDirectoryError, CreateDirectoryRequest, CreateFileError,
|
file::{
|
||||||
CreateFileRequest, DeleteDirectoryError, DeleteDirectoryRequest, DeleteFileError,
|
AbsoluteFilePath, CatError, CatRequest, File, FileMimeType, FileName, FilePath,
|
||||||
DeleteFileRequest, FetchFileError, FetchFileRequest, File, FileMimeType, FileName,
|
FileStream, FileType, LsError, LsRequest, MkdirError, MkdirRequest, MvError,
|
||||||
FilePath, FileStream, FileType, ListFilesError, ListFilesRequest, RenameEntryError,
|
MvRequest, RelativeFilePath, RmError, RmRequest, SaveError, SaveRequest,
|
||||||
RenameEntryRequest,
|
SaveResponse, TouchError, TouchRequest,
|
||||||
|
},
|
||||||
|
warren::UploadFileStream,
|
||||||
},
|
},
|
||||||
ports::FileSystemRepository,
|
ports::FileSystemRepository,
|
||||||
},
|
},
|
||||||
@@ -129,49 +132,65 @@ impl FileSystem {
|
|||||||
/// Actually created a directory in the underlying file system
|
/// Actually created a directory in the underlying file system
|
||||||
///
|
///
|
||||||
/// * `path`: The directory's absolute path (absolute not in relation to the root file system but `self.base_directory`)
|
/// * `path`: The directory's absolute path (absolute not in relation to the root file system but `self.base_directory`)
|
||||||
async fn create_dir(&self, path: &AbsoluteFilePath) -> io::Result<FilePath> {
|
async fn mkdir(&self, path: &AbsoluteFilePath) -> io::Result<()> {
|
||||||
let file_path = self.get_target_path(path);
|
let file_path = self.get_target_path(path);
|
||||||
|
|
||||||
if fs::try_exists(&file_path).await? {
|
if fs::try_exists(&file_path).await? {
|
||||||
return Err(io::ErrorKind::AlreadyExists.into());
|
return Err(io::ErrorKind::AlreadyExists.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::create_dir(&file_path).await?;
|
fs::create_dir(&file_path).await
|
||||||
|
|
||||||
Ok(file_path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Actually removes a directory from the underlying file system
|
/// Actually removes a file or directory from the underlying file system
|
||||||
///
|
///
|
||||||
/// * `path`: The directory's absolute path (absolute not in relation to the root file system but `self.base_directory`)
|
/// * `path`: The directory's absolute path (absolute not in relation to the root file system but `self.base_directory`)
|
||||||
/// * `force`: Whether to delete directories that are not empty
|
/// * `force`: Whether to delete directories that are not empty
|
||||||
async fn remove_dir(&self, path: &AbsoluteFilePath, force: bool) -> io::Result<FilePath> {
|
async fn rm(&self, path: &AbsoluteFilePath, force: bool) -> io::Result<()> {
|
||||||
let file_path = self.get_target_path(path);
|
let file_path = self.get_target_path(path);
|
||||||
|
|
||||||
if force {
|
if fs::metadata(&file_path).await?.is_file() {
|
||||||
fs::remove_dir_all(&file_path).await?;
|
return fs::remove_file(&file_path).await;
|
||||||
} else {
|
|
||||||
fs::remove_dir(&file_path).await?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(file_path)
|
if force {
|
||||||
|
fs::remove_dir_all(&file_path).await
|
||||||
|
} else {
|
||||||
|
fs::remove_dir(&file_path).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn write_file(&self, path: &AbsoluteFilePath, data: &[u8]) -> anyhow::Result<FilePath> {
|
async fn save(
|
||||||
let path = self.get_target_path(path);
|
&self,
|
||||||
|
path: &AbsoluteFilePath,
|
||||||
|
stream: &mut UploadFileStream<'_>,
|
||||||
|
) -> anyhow::Result<Vec<AbsoluteFilePath>> {
|
||||||
|
let base_path = self.get_target_path(path);
|
||||||
|
|
||||||
let mut file = fs::OpenOptions::new()
|
let paths = Vec::new();
|
||||||
.write(true)
|
|
||||||
.create(true)
|
|
||||||
.open(&path)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
file.write_all(data).await?;
|
while let Ok(Some(mut upload_file)) = stream.try_next().await {
|
||||||
|
// TODO: Refactor this result question mark chain thing
|
||||||
|
let file_name_as_path: RelativeFilePath =
|
||||||
|
FilePath::new(upload_file.file_name().as_str())?.try_into()?;
|
||||||
|
let file_path = base_path.join(&file_name_as_path);
|
||||||
|
|
||||||
Ok(path)
|
let mut file = fs::OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.open(&file_path)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Ok(Some(chunk)) = upload_file.try_next().await {
|
||||||
|
tracing::info!("Writing chunk (len: {}) to {file_path}", chunk.len());
|
||||||
|
file.write(&chunk).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_file(&self, path: &AbsoluteFilePath) -> anyhow::Result<FileStream> {
|
async fn cat(&self, path: &AbsoluteFilePath) -> anyhow::Result<FileStream> {
|
||||||
let path = self.get_target_path(path);
|
let path = self.get_target_path(path);
|
||||||
|
|
||||||
let file = fs::OpenOptions::new()
|
let file = fs::OpenOptions::new()
|
||||||
@@ -192,45 +211,30 @@ impl FileSystem {
|
|||||||
Ok(stream)
|
Ok(stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Actually removes a file from the underlying file system
|
async fn mv(&self, path: &AbsoluteFilePath, target_path: &AbsoluteFilePath) -> io::Result<()> {
|
||||||
///
|
|
||||||
/// * `path`: The file's absolute path (absolute not in relation to the root file system but `self.base_directory`)
|
|
||||||
async fn remove_file(&self, path: &AbsoluteFilePath) -> anyhow::Result<FilePath> {
|
|
||||||
let path = self.get_target_path(path);
|
|
||||||
|
|
||||||
fs::remove_file(&path).await?;
|
|
||||||
|
|
||||||
Ok(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn rename(
|
|
||||||
&self,
|
|
||||||
path: &AbsoluteFilePath,
|
|
||||||
new_name: &FileName,
|
|
||||||
) -> anyhow::Result<FilePath> {
|
|
||||||
let current_path = self.get_target_path(path);
|
let current_path = self.get_target_path(path);
|
||||||
|
let target_path = self.get_target_path(target_path);
|
||||||
|
|
||||||
let new_path = {
|
if !fs::try_exists(¤t_path).await? {
|
||||||
let mut c = current_path.to_string();
|
return Err(io::ErrorKind::NotFound.into());
|
||||||
let last_slash_index = c.rfind('/').unwrap();
|
|
||||||
c.drain((last_slash_index + 1)..);
|
|
||||||
c.push_str(new_name.as_str());
|
|
||||||
|
|
||||||
FilePath::new(&c)?
|
|
||||||
};
|
|
||||||
|
|
||||||
if fs::try_exists(&new_path).await? {
|
|
||||||
bail!("File exists");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::rename(current_path, &new_path).await?;
|
if fs::try_exists(&target_path).await? {
|
||||||
|
return Err(io::ErrorKind::AlreadyExists.into());
|
||||||
|
}
|
||||||
|
|
||||||
Ok(new_path)
|
fs::rename(current_path, &target_path).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn touch(&self, path: &AbsoluteFilePath) -> io::Result<()> {
|
||||||
|
let path = self.get_target_path(path);
|
||||||
|
|
||||||
|
tokio::fs::File::create(&path).await.map(|_| ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileSystemRepository for FileSystem {
|
impl FileSystemRepository for FileSystem {
|
||||||
async fn list_files(&self, request: ListFilesRequest) -> Result<Vec<File>, ListFilesError> {
|
async fn ls(&self, request: LsRequest) -> Result<Vec<File>, LsError> {
|
||||||
let files = self.get_all_files(request.path()).await.map_err(|err| {
|
let files = self.get_all_files(request.path()).await.map_err(|err| {
|
||||||
anyhow!(err).context(format!(
|
anyhow!(err).context(format!(
|
||||||
"Failed to get the files at path: {}",
|
"Failed to get the files at path: {}",
|
||||||
@@ -241,81 +245,56 @@ impl FileSystemRepository for FileSystem {
|
|||||||
Ok(files)
|
Ok(files)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_directory(
|
async fn cat(&self, request: CatRequest) -> Result<FileStream, CatError> {
|
||||||
&self,
|
self.cat(request.path())
|
||||||
request: CreateDirectoryRequest,
|
|
||||||
) -> Result<FilePath, CreateDirectoryError> {
|
|
||||||
match self.create_dir(request.path()).await {
|
|
||||||
Ok(path) => Ok(path),
|
|
||||||
Err(e) => match e.kind() {
|
|
||||||
std::io::ErrorKind::AlreadyExists => Err(CreateDirectoryError::Exists),
|
|
||||||
_ => Err(anyhow!("Failed to create directory at path: {}", request.path()).into()),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn delete_directory(
|
|
||||||
&self,
|
|
||||||
request: DeleteDirectoryRequest,
|
|
||||||
) -> Result<FilePath, DeleteDirectoryError> {
|
|
||||||
match self.remove_dir(request.path(), request.force()).await {
|
|
||||||
Ok(deleted_path) => return Ok(deleted_path),
|
|
||||||
Err(e) => match e.kind() {
|
|
||||||
std::io::ErrorKind::NotFound => Err(DeleteDirectoryError::NotFound),
|
|
||||||
std::io::ErrorKind::DirectoryNotEmpty => Err(DeleteDirectoryError::NotEmpty),
|
|
||||||
_ => Err(anyhow!("Failed to delete directory at {}: {e:?}", request.path()).into()),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn create_file(&self, request: CreateFileRequest) -> Result<FilePath, CreateFileError> {
|
|
||||||
let file_path = self
|
|
||||||
.write_file(request.path(), request.data())
|
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| anyhow!("Failed to fetch file {}: {e:?}", request.path()).into())
|
||||||
anyhow!(
|
|
||||||
"Failed to write {} byte(s) to path {}: {e:?}",
|
|
||||||
request.data().len(),
|
|
||||||
request.path()
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok(file_path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_file(&self, request: FetchFileRequest) -> Result<FileStream, FetchFileError> {
|
async fn mkdir(&self, request: MkdirRequest) -> Result<(), MkdirError> {
|
||||||
let contents = self
|
self.mkdir(request.path())
|
||||||
.fetch_file(request.path())
|
|
||||||
.await
|
.await
|
||||||
.map_err(|e| anyhow!("Failed to fetch file {}: {e:?}", request.path()))?;
|
.map_err(|e| match e.kind() {
|
||||||
|
std::io::ErrorKind::AlreadyExists => MkdirError::Exists,
|
||||||
Ok(contents)
|
_ => anyhow!("Failed to create directory at path: {}", request.path()).into(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_file(&self, request: DeleteFileRequest) -> Result<FilePath, DeleteFileError> {
|
async fn rm(&self, request: RmRequest) -> Result<(), RmError> {
|
||||||
let deleted_path = self
|
self.rm(request.path(), request.force())
|
||||||
.remove_file(request.path())
|
|
||||||
.await
|
.await
|
||||||
.context(format!("Failed to delete file at {}", request.path()))?;
|
.map_err(|e| match e.kind() {
|
||||||
|
std::io::ErrorKind::NotFound => RmError::NotFound,
|
||||||
Ok(deleted_path)
|
std::io::ErrorKind::DirectoryNotEmpty => RmError::NotEmpty,
|
||||||
|
_ => anyhow!("Failed to delete file at {}: {e:?}", request.path()).into(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn rename_entry(
|
async fn mv(&self, request: MvRequest) -> Result<(), MvError> {
|
||||||
&self,
|
self.mv(request.path(), request.target_path())
|
||||||
request: RenameEntryRequest,
|
|
||||||
) -> Result<FilePath, RenameEntryError> {
|
|
||||||
let new_path = self
|
|
||||||
.rename(request.path(), request.new_name())
|
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| match e.kind() {
|
||||||
anyhow!(
|
std::io::ErrorKind::NotFound => MvError::NotFound,
|
||||||
"Failed to rename {} to {}: {e:?}",
|
_ => anyhow!(
|
||||||
|
"Failed to move {} to {}: {e:?}",
|
||||||
request.path(),
|
request.path(),
|
||||||
request.new_name()
|
request.target_path()
|
||||||
)
|
)
|
||||||
})?;
|
.into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Ok(new_path)
|
async fn touch(&self, request: TouchRequest) -> Result<(), TouchError> {
|
||||||
|
self.touch(request.path())
|
||||||
|
.await
|
||||||
|
.map_err(|e| match e.kind() {
|
||||||
|
std::io::ErrorKind::NotFound => TouchError::NotFound,
|
||||||
|
_ => anyhow!("Failed to touch path {}: {e:?}", request.path()).into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn save(&self, request: SaveRequest<'_>) -> Result<SaveResponse, SaveError> {
|
||||||
|
let (path, mut stream) = request.unpack();
|
||||||
|
Ok(self.save(&path, &mut stream).await.map(SaveResponse::new)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,114 +52,104 @@ impl WarrenMetrics for MetricsDebugLogger {
|
|||||||
tracing::debug!("[Metrics] Fetch warrens failed");
|
tracing::debug!("[Metrics] Fetch warrens failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_warren_fetch_file_success(&self) {
|
async fn record_warren_ls_success(&self) {
|
||||||
tracing::debug!("[Metrics] Fetch warren file succeeded");
|
|
||||||
}
|
|
||||||
async fn record_warren_fetch_file_failure(&self) {
|
|
||||||
tracing::debug!("[Metrics] Fetch warren file failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn record_list_warren_files_success(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren list files succeeded");
|
tracing::debug!("[Metrics] Warren list files succeeded");
|
||||||
}
|
}
|
||||||
|
async fn record_warren_ls_failure(&self) {
|
||||||
async fn record_list_warren_files_failure(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren list files failed");
|
tracing::debug!("[Metrics] Warren list files failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_warren_directory_creation_success(&self) {
|
async fn record_warren_cat_success(&self) {
|
||||||
tracing::debug!("[Metrics] Warren directory creation succeeded");
|
tracing::debug!("[Metrics] Fetch warren file succeeded");
|
||||||
|
}
|
||||||
|
async fn record_warren_cat_failure(&self) {
|
||||||
|
tracing::debug!("[Metrics] Fetch warren file failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_warren_directory_creation_failure(&self) {
|
async fn record_warren_mkdir_success(&self) {
|
||||||
|
tracing::debug!("[Metrics] Warren directory creation succeeded");
|
||||||
|
}
|
||||||
|
async fn record_warren_mkdir_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Warren directory creation failed");
|
tracing::debug!("[Metrics] Warren directory creation failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_warren_directory_deletion_success(&self) {
|
async fn record_warren_rm_success(&self) {
|
||||||
tracing::debug!("[Metrics] Warren directory deletion succeeded");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn record_warren_directory_deletion_failure(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren directory deletion failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn record_warren_file_upload_success(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren file upload succeeded");
|
|
||||||
}
|
|
||||||
async fn record_warren_file_upload_failure(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren file upload failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn record_warren_files_upload_success(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren files upload succeded");
|
|
||||||
}
|
|
||||||
async fn record_warren_files_upload_failure(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren files upload failed at least partially");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn record_warren_file_deletion_success(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren file deletion succeeded");
|
tracing::debug!("[Metrics] Warren file deletion succeeded");
|
||||||
}
|
}
|
||||||
async fn record_warren_file_deletion_failure(&self) {
|
async fn record_warren_rm_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Warren file deletion failed");
|
tracing::debug!("[Metrics] Warren file deletion failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_warren_entry_rename_success(&self) {
|
async fn record_warren_mv_success(&self) {
|
||||||
tracing::debug!("[Metrics] Warren entry rename succeeded");
|
tracing::debug!("[Metrics] Warren entry rename succeeded");
|
||||||
}
|
}
|
||||||
async fn record_warren_entry_rename_failure(&self) {
|
async fn record_warren_mv_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Warren entry rename failed");
|
tracing::debug!("[Metrics] Warren entry rename failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn record_warren_save_success(&self) {
|
||||||
|
tracing::debug!("[Metrics] Warren file upload succeeded");
|
||||||
|
}
|
||||||
|
async fn record_warren_save_failure(&self) {
|
||||||
|
tracing::debug!("[Metrics] Warren file upload failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn record_warren_touch_success(&self) {
|
||||||
|
tracing::debug!("[Metrics] Warren entry touch succeeded");
|
||||||
|
}
|
||||||
|
async fn record_warren_touch_failure(&self) {
|
||||||
|
tracing::debug!("[Metrics] Warren entry touch failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileSystemMetrics for MetricsDebugLogger {
|
impl FileSystemMetrics for MetricsDebugLogger {
|
||||||
async fn record_list_files_success(&self) {
|
async fn record_ls_success(&self) {
|
||||||
tracing::debug!("[Metrics] File list succeeded");
|
tracing::debug!("[Metrics] Ls succeeded");
|
||||||
}
|
}
|
||||||
async fn record_list_files_failure(&self) {
|
async fn record_ls_failure(&self) {
|
||||||
tracing::debug!("[Metrics] File list failed");
|
tracing::debug!("[Metrics] Ls failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_directory_creation_success(&self) {
|
async fn record_cat_success(&self) {
|
||||||
tracing::debug!("[Metrics] Directory creation succeeded");
|
tracing::debug!("[Metrics] Cat succeeded");
|
||||||
}
|
}
|
||||||
async fn record_directory_creation_failure(&self) {
|
async fn record_cat_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Directory creation failed");
|
tracing::debug!("[Metrics] Cat failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_directory_deletion_success(&self) {
|
async fn record_mkdir_success(&self) {
|
||||||
tracing::debug!("[Metrics] Directory deletion succeeded");
|
tracing::debug!("[Metrics] Mkdir succeeded");
|
||||||
}
|
}
|
||||||
async fn record_directory_deletion_failure(&self) {
|
async fn record_mkdir_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Directory deletion failed");
|
tracing::debug!("[Metrics] Mkdir failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_file_creation_success(&self) {
|
async fn record_rm_success(&self) {
|
||||||
tracing::debug!("[Metrics] File creation succeeded");
|
tracing::debug!("[Metrics] Rm succeeded");
|
||||||
}
|
}
|
||||||
async fn record_file_creation_failure(&self) {
|
async fn record_rm_failure(&self) {
|
||||||
tracing::debug!("[Metrics] File creation failed");
|
tracing::debug!("[Metrics] Rm failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_file_fetch_success(&self) {
|
async fn record_mv_success(&self) {
|
||||||
tracing::debug!("[Metrics] File fetch succeeded");
|
tracing::debug!("[Metrics] Mv succeeded");
|
||||||
}
|
}
|
||||||
async fn record_file_fetch_failure(&self) {
|
async fn record_mv_failure(&self) {
|
||||||
tracing::debug!("[Metrics] File fetch failed");
|
tracing::debug!("[Metrics] Mv failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_file_deletion_success(&self) {
|
async fn record_save_success(&self) {
|
||||||
tracing::debug!("[Metrics] File deletion succeeded");
|
tracing::debug!("[Metrics] Save succeeded");
|
||||||
}
|
}
|
||||||
async fn record_file_deletion_failure(&self) {
|
async fn record_save_failure(&self) {
|
||||||
tracing::debug!("[Metrics] File deletion failed");
|
tracing::debug!("[Metrics] Save failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_entry_rename_success(&self) {
|
async fn record_touch_success(&self) {
|
||||||
tracing::debug!("[Metrics] Entry rename succeeded");
|
tracing::debug!("[Metrics] Touch succeeded");
|
||||||
}
|
}
|
||||||
async fn record_entry_rename_failure(&self) {
|
async fn record_touch_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Entry rename failed");
|
tracing::debug!("[Metrics] Touch failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,13 +259,6 @@ impl AuthMetrics for MetricsDebugLogger {
|
|||||||
tracing::debug!("[Metrics] User warren deletion failed");
|
tracing::debug!("[Metrics] User warren deletion failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_auth_warren_fetch_file_success(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren file fetch succeeded");
|
|
||||||
}
|
|
||||||
async fn record_auth_warren_fetch_file_failure(&self) {
|
|
||||||
tracing::debug!("[Metrics] Warren file fetch failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn record_auth_fetch_user_warren_list_success(&self) {
|
async fn record_auth_fetch_user_warren_list_success(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren list succeeded");
|
tracing::debug!("[Metrics] Auth warren list succeeded");
|
||||||
}
|
}
|
||||||
@@ -297,45 +280,52 @@ impl AuthMetrics for MetricsDebugLogger {
|
|||||||
tracing::debug!("[Metrics] Auth warren fetch failed");
|
tracing::debug!("[Metrics] Auth warren fetch failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_auth_warren_file_list_success(&self) {
|
async fn record_auth_warren_ls_success(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren file list succeeded");
|
tracing::debug!("[Metrics] Auth warren ls succeeded");
|
||||||
}
|
}
|
||||||
async fn record_auth_warren_file_list_failure(&self) {
|
async fn record_auth_warren_ls_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren file list failed");
|
tracing::debug!("[Metrics] Auth warren ls failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_auth_warren_directory_creation_success(&self) {
|
async fn record_auth_warren_cat_success(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren directory creation succeeded");
|
tracing::debug!("[Metrics] Warren file fetch succeeded");
|
||||||
}
|
}
|
||||||
async fn record_auth_warren_directory_creation_failure(&self) {
|
async fn record_auth_warren_cat_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren directory creation failed");
|
tracing::debug!("[Metrics] Warren file fetch failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_auth_warren_directory_deletion_success(&self) {
|
async fn record_auth_warren_mkdir_success(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren directory deletion succeeded");
|
tracing::debug!("[Metrics] Auth warren mkdir succeeded");
|
||||||
}
|
}
|
||||||
async fn record_auth_warren_directory_deletion_failure(&self) {
|
async fn record_auth_warren_mkdir_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren directory deletion failed");
|
tracing::debug!("[Metrics] Auth warren mkdir failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_auth_warren_file_deletion_success(&self) {
|
async fn record_auth_warren_rm_success(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren file deletion succeeded");
|
tracing::debug!("[Metrics] Auth warren rm succeeded");
|
||||||
}
|
}
|
||||||
async fn record_auth_warren_file_deletion_failure(&self) {
|
async fn record_auth_warren_rm_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren file deletion failed");
|
tracing::debug!("[Metrics] Auth warren rm failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_auth_warren_entry_rename_success(&self) {
|
async fn record_auth_warren_mv_success(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren entry rename succeeded");
|
tracing::debug!("[Metrics] Auth warren mv succeeded");
|
||||||
}
|
}
|
||||||
async fn record_auth_warren_entry_rename_failure(&self) {
|
async fn record_auth_warren_mv_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren entry rename failed");
|
tracing::debug!("[Metrics] Auth warren mv failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn record_auth_warren_files_upload_success(&self) {
|
async fn record_auth_warren_save_success(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren files upload succeeded");
|
tracing::debug!("[Metrics] Auth warren save succeeded");
|
||||||
}
|
}
|
||||||
async fn record_auth_warren_files_upload_failure(&self) {
|
async fn record_auth_warren_save_failure(&self) {
|
||||||
tracing::debug!("[Metrics] Auth warren files upload failed");
|
tracing::debug!("[Metrics] Auth warren save failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn record_auth_warren_touch_success(&self) {
|
||||||
|
tracing::debug!("[Metrics] Auth warren touch succeeded");
|
||||||
|
}
|
||||||
|
async fn record_auth_warren_touch_failure(&self) {
|
||||||
|
tracing::debug!("[Metrics] Auth warren touch failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ use uuid::Uuid;
|
|||||||
use crate::domain::warren::{
|
use crate::domain::warren::{
|
||||||
models::{
|
models::{
|
||||||
auth_session::requests::FetchAuthSessionResponse,
|
auth_session::requests::FetchAuthSessionResponse,
|
||||||
file::{AbsoluteFilePath, File, FilePath},
|
file::{AbsoluteFilePath, File},
|
||||||
user::{ListAllUsersAndWarrensResponse, LoginUserResponse, User},
|
user::{ListAllUsersAndWarrensResponse, LoginUserResponse, User},
|
||||||
user_warren::UserWarren,
|
user_warren::UserWarren,
|
||||||
warren::{
|
warren::{
|
||||||
CreateWarrenDirectoryResponse, DeleteWarrenDirectoryResponse, DeleteWarrenFileResponse,
|
Warren, WarrenLsResponse, WarrenMkdirResponse, WarrenMvResponse, WarrenRmResponse,
|
||||||
ListWarrenFilesResponse, RenameWarrenEntryResponse, UploadWarrenFilesResponse, Warren,
|
WarrenSaveResponse, WarrenTouchResponse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ports::{AuthNotifier, FileSystemNotifier, WarrenNotifier},
|
ports::{AuthNotifier, FileSystemNotifier, WarrenNotifier},
|
||||||
@@ -46,7 +46,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
|||||||
tracing::debug!("[Notifier] Fetched warren {}", warren.name());
|
tracing::debug!("[Notifier] Fetched warren {}", warren.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn warren_file_fetched(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
async fn warren_cat(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Fetched file {} in warren {}",
|
"[Notifier] Fetched file {} in warren {}",
|
||||||
path,
|
path,
|
||||||
@@ -54,7 +54,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn warren_files_listed(&self, response: &ListWarrenFilesResponse) {
|
async fn warren_ls(&self, response: &WarrenLsResponse) {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Listed {} file(s) in warren {}",
|
"[Notifier] Listed {} file(s) in warren {}",
|
||||||
response.files().len(),
|
response.files().len(),
|
||||||
@@ -62,7 +62,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn warren_directory_created(&self, response: &CreateWarrenDirectoryResponse) {
|
async fn warren_mkdir(&self, response: &WarrenMkdirResponse) {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Created directory {} in warren {}",
|
"[Notifier] Created directory {} in warren {}",
|
||||||
response.path(),
|
response.path(),
|
||||||
@@ -70,31 +70,11 @@ impl WarrenNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn warren_directory_deleted(&self, response: &DeleteWarrenDirectoryResponse) {
|
async fn warren_save(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
||||||
tracing::debug!(
|
tracing::debug!("[Notifier] Saved file {} to warren {}", path, warren.name());
|
||||||
"[Notifier] Deleted directory {} in warren {}",
|
|
||||||
response.path(),
|
|
||||||
response.warren().name()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn warren_file_uploaded(&self, warren: &Warren, path: &FilePath) {
|
async fn warren_rm(&self, response: &WarrenRmResponse) {
|
||||||
tracing::debug!(
|
|
||||||
"[Notifier] Uploaded file {} to warren {}",
|
|
||||||
path,
|
|
||||||
warren.name()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn warren_files_uploaded(&self, response: &UploadWarrenFilesResponse) {
|
|
||||||
tracing::debug!(
|
|
||||||
"[Notifier] Uploaded {} file(s) to warren {}",
|
|
||||||
response.paths().len(),
|
|
||||||
response.warren().name()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn warren_file_deleted(&self, response: &DeleteWarrenFileResponse) {
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Deleted file {} from warren {}",
|
"[Notifier] Deleted file {} from warren {}",
|
||||||
response.path(),
|
response.path(),
|
||||||
@@ -102,7 +82,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn warren_entry_renamed(&self, response: &RenameWarrenEntryResponse) {
|
async fn warren_mv(&self, response: &WarrenMvResponse) {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Renamed file {} to {} in warren {}",
|
"[Notifier] Renamed file {} to {} in warren {}",
|
||||||
response.old_path(),
|
response.old_path(),
|
||||||
@@ -110,36 +90,44 @@ impl WarrenNotifier for NotifierDebugLogger {
|
|||||||
response.warren().name(),
|
response.warren().name(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn warren_touch(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
||||||
|
tracing::debug!(
|
||||||
|
"[Notifier] Touched file {} in warren {}",
|
||||||
|
path,
|
||||||
|
warren.name()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileSystemNotifier for NotifierDebugLogger {
|
impl FileSystemNotifier for NotifierDebugLogger {
|
||||||
async fn files_listed(&self, files: &Vec<File>) {
|
async fn ls(&self, files: &Vec<File>) {
|
||||||
tracing::debug!("[Notifier] Listed {} file(s)", files.len());
|
tracing::debug!("[Notifier] Listed {} file(s)", files.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn directory_created(&self, path: &FilePath) {
|
async fn cat(&self, path: &AbsoluteFilePath) {
|
||||||
tracing::debug!("[Notifier] Created directory {}", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn directory_deleted(&self, path: &FilePath) {
|
|
||||||
tracing::debug!("[Notifier] Deleted directory {}", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn file_created(&self, path: &FilePath) {
|
|
||||||
tracing::debug!("[Notifier] Created file {}", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn file_fetched(&self, path: &AbsoluteFilePath) {
|
|
||||||
tracing::debug!("[Notifier] Fetched file {path}");
|
tracing::debug!("[Notifier] Fetched file {path}");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn file_deleted(&self, path: &FilePath) {
|
async fn mkdir(&self, path: &AbsoluteFilePath) {
|
||||||
|
tracing::debug!("[Notifier] Created directory {}", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn rm(&self, path: &AbsoluteFilePath) {
|
||||||
tracing::debug!("[Notifier] Deleted file {}", path);
|
tracing::debug!("[Notifier] Deleted file {}", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn entry_renamed(&self, old_path: &FilePath, new_path: &FilePath) {
|
async fn mv(&self, old_path: &AbsoluteFilePath, new_path: &AbsoluteFilePath) {
|
||||||
tracing::debug!("[Notifier] Renamed file {} to {}", old_path, new_path);
|
tracing::debug!("[Notifier] Renamed file {} to {}", old_path, new_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn save(&self, path: &AbsoluteFilePath) {
|
||||||
|
tracing::debug!("[Notifier] Saved file {}", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn touch(&self, path: &AbsoluteFilePath) {
|
||||||
|
tracing::debug!("[Notifier] Touched file {}", path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AuthNotifier for NotifierDebugLogger {
|
impl AuthNotifier for NotifierDebugLogger {
|
||||||
@@ -281,19 +269,14 @@ impl AuthNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_warren_file_fetched(
|
async fn auth_warren_cat(&self, user: &User, warren_id: &Uuid, path: &AbsoluteFilePath) {
|
||||||
&self,
|
|
||||||
user: &User,
|
|
||||||
warren_id: &Uuid,
|
|
||||||
path: &AbsoluteFilePath,
|
|
||||||
) {
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] User {} fetched file {path} in warren {warren_id}",
|
"[Notifier] User {} fetched file {path} in warren {warren_id}",
|
||||||
user.id(),
|
user.id(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_warren_files_listed(&self, user: &User, response: &ListWarrenFilesResponse) {
|
async fn auth_warren_ls(&self, user: &User, response: &WarrenLsResponse) {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Listed {} file(s) in warren {} for authenticated user {}",
|
"[Notifier] Listed {} file(s) in warren {} for authenticated user {}",
|
||||||
response.files().len(),
|
response.files().len(),
|
||||||
@@ -302,11 +285,7 @@ impl AuthNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_warren_directory_created(
|
async fn auth_warren_mkdir(&self, user: &User, response: &WarrenMkdirResponse) {
|
||||||
&self,
|
|
||||||
user: &User,
|
|
||||||
response: &CreateWarrenDirectoryResponse,
|
|
||||||
) {
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Created directory {} in warren {} for authenticated user {}",
|
"[Notifier] Created directory {} in warren {} for authenticated user {}",
|
||||||
response.path(),
|
response.path(),
|
||||||
@@ -315,29 +294,16 @@ impl AuthNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_warren_directory_deleted(
|
async fn auth_warren_save(&self, user: &User, response: &WarrenSaveResponse) {
|
||||||
&self,
|
|
||||||
user: &User,
|
|
||||||
response: &DeleteWarrenDirectoryResponse,
|
|
||||||
) {
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Deleted directory {} in warren {} for authenticated user {}",
|
"[Notifier] Uploaded file {} to warren {} for authenticated user {}",
|
||||||
response.path(),
|
response.path(),
|
||||||
response.warren().name(),
|
response.warren().name(),
|
||||||
user.id(),
|
user.id(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_warren_files_uploaded(&self, user: &User, response: &UploadWarrenFilesResponse) {
|
async fn auth_warren_rm(&self, user: &User, response: &WarrenRmResponse) {
|
||||||
tracing::debug!(
|
|
||||||
"[Notifier] Uploaded {} file(s) to warren {} for authenticated user {}",
|
|
||||||
response.paths().len(),
|
|
||||||
response.warren().name(),
|
|
||||||
user.id(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn auth_warren_file_deleted(&self, user: &User, response: &DeleteWarrenFileResponse) {
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Deleted file {} from warren {} for authenticated user {}",
|
"[Notifier] Deleted file {} from warren {} for authenticated user {}",
|
||||||
response.path(),
|
response.path(),
|
||||||
@@ -346,7 +312,7 @@ impl AuthNotifier for NotifierDebugLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_warren_entry_renamed(&self, user: &User, response: &RenameWarrenEntryResponse) {
|
async fn auth_warren_mv(&self, user: &User, response: &WarrenMvResponse) {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"[Notifier] Renamed file {} to {} in warren {} for authenticated user {}",
|
"[Notifier] Renamed file {} to {} in warren {} for authenticated user {}",
|
||||||
response.old_path(),
|
response.old_path(),
|
||||||
@@ -355,4 +321,13 @@ impl AuthNotifier for NotifierDebugLogger {
|
|||||||
user.id(),
|
user.id(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn auth_warren_touch(&self, user: &User, response: &WarrenTouchResponse) {
|
||||||
|
tracing::debug!(
|
||||||
|
"[Notifier] Touched file {} in warren {} for authenticated user {}",
|
||||||
|
response.path(),
|
||||||
|
response.warren().name(),
|
||||||
|
user.id()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function onFilesChanged(event: Event) {
|
|||||||
|
|
||||||
if (uploadStore.destination == null) {
|
if (uploadStore.destination == null) {
|
||||||
uploadStore.destination = warrenStore.current;
|
uploadStore.destination = warrenStore.current;
|
||||||
} else if (currentAndUploadRouteMatch.value) {
|
} else if (!currentAndUploadRouteMatch.value) {
|
||||||
toast.warning('Upload', {
|
toast.warning('Upload', {
|
||||||
description:
|
description:
|
||||||
'The unfinished items belong to a different directory. Remove them before attempting to upload to a different directory.',
|
'The unfinished items belong to a different directory. Remove them before attempting to upload to a different directory.',
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ function createObjectUrl(file: File): string {
|
|||||||
{ 'p-2': !file.data.type.startsWith('image/') },
|
{ 'p-2': !file.data.type.startsWith('image/') },
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<div v-if="file.status === 'not_uploaded'" class="h-full w-full">
|
<div
|
||||||
|
v-if="file.status === 'not_uploaded'"
|
||||||
|
class="flex h-full w-full items-center justify-center"
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
v-if="file.data.type.startsWith('image/')"
|
v-if="file.data.type.startsWith('image/')"
|
||||||
:src="createObjectUrl(file.data)"
|
:src="createObjectUrl(file.data)"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export async function getWarrenDirectory(
|
|||||||
): Promise<DirectoryEntry[]> {
|
): Promise<DirectoryEntry[]> {
|
||||||
const { data, error } = await useFetch<
|
const { data, error } = await useFetch<
|
||||||
ApiResponse<{ files: DirectoryEntry[] }>
|
ApiResponse<{ files: DirectoryEntry[] }>
|
||||||
>(getApiUrl(`warrens/files`), {
|
>(getApiUrl(`warrens/files/ls`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: getApiHeaders(),
|
headers: getApiHeaders(),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -60,7 +60,7 @@ export async function createDirectory(
|
|||||||
|
|
||||||
path += directoryName;
|
path += directoryName;
|
||||||
|
|
||||||
const { status } = await useFetch(getApiUrl(`warrens/files/directory`), {
|
const { status } = await useFetch(getApiUrl(`warrens/files/mkdir`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: getApiHeaders(),
|
headers: getApiHeaders(),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -99,8 +99,8 @@ export async function deleteWarrenDirectory(
|
|||||||
|
|
||||||
path += directoryName;
|
path += directoryName;
|
||||||
|
|
||||||
const { status } = await useFetch(getApiUrl(`warrens/files/directory`), {
|
const { status } = await useFetch(getApiUrl(`warrens/files/rm`), {
|
||||||
method: 'DELETE',
|
method: 'POST',
|
||||||
headers: getApiHeaders(),
|
headers: getApiHeaders(),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
warrenId,
|
warrenId,
|
||||||
@@ -139,12 +139,13 @@ export async function deleteWarrenFile(
|
|||||||
|
|
||||||
path += fileName;
|
path += fileName;
|
||||||
|
|
||||||
const { status } = await useFetch(getApiUrl(`warrens/files/file`), {
|
const { status } = await useFetch(getApiUrl(`warrens/files/rm`), {
|
||||||
method: 'DELETE',
|
method: 'POST',
|
||||||
headers: getApiHeaders(),
|
headers: getApiHeaders(),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
warrenId,
|
warrenId,
|
||||||
path,
|
path,
|
||||||
|
force: false,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -174,7 +175,7 @@ export async function uploadToWarren(
|
|||||||
onProgress: ((loaded: number, total: number) => void) | undefined
|
onProgress: ((loaded: number, total: number) => void) | undefined
|
||||||
): Promise<{ success: boolean }> {
|
): Promise<{ success: boolean }> {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', getApiUrl(`warrens/files/upload`));
|
xhr.open('POST', getApiUrl(`warrens/files/save`));
|
||||||
xhr.upload.onprogress = (e) => {
|
xhr.upload.onprogress = (e) => {
|
||||||
onProgress?.(e.loaded, e.total);
|
onProgress?.(e.loaded, e.total);
|
||||||
};
|
};
|
||||||
@@ -236,15 +237,17 @@ export async function renameWarrenEntry(
|
|||||||
if (!path.endsWith('/')) {
|
if (!path.endsWith('/')) {
|
||||||
path += '/';
|
path += '/';
|
||||||
}
|
}
|
||||||
|
let targetPath = path;
|
||||||
|
targetPath += newName;
|
||||||
path += currentName;
|
path += currentName;
|
||||||
|
|
||||||
const { status } = await useFetch(getApiUrl(`warrens/files/rename`), {
|
const { status } = await useFetch(getApiUrl(`warrens/files/mv`), {
|
||||||
method: 'PATCH',
|
method: 'POST',
|
||||||
headers: getApiHeaders(),
|
headers: getApiHeaders(),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
warrenId,
|
warrenId,
|
||||||
path,
|
path,
|
||||||
newName,
|
targetPath,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -277,7 +280,7 @@ export async function fetchFile(
|
|||||||
path += fileName;
|
path += fileName;
|
||||||
|
|
||||||
const { data, error } = await useFetch<Blob>(
|
const { data, error } = await useFetch<Blob>(
|
||||||
getApiUrl(`warrens/files/fetch?warrenId=${warrenId}&path=${path}`),
|
getApiUrl(`warrens/files/cat?warrenId=${warrenId}&path=${path}`),
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: getApiHeaders(),
|
headers: getApiHeaders(),
|
||||||
|
|||||||
Reference in New Issue
Block a user