Lock file maintenance #8
9 changed files with 7607 additions and 15040 deletions
86
Cargo.lock
generated
86
Cargo.lock
generated
|
@ -875,9 +875,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.2"
|
version = "1.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
|
checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -1011,7 +1011,7 @@ dependencies = [
|
||||||
"eyre",
|
"eyre",
|
||||||
"rustls 0.23.19",
|
"rustls 0.23.19",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls 0.26.0",
|
"tokio-rustls 0.26.1",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
@ -1036,7 +1036,6 @@ dependencies = [
|
||||||
"mime",
|
"mime",
|
||||||
"rusty_paseto",
|
"rusty_paseto",
|
||||||
"sentry-tower",
|
"sentry-tower",
|
||||||
"serde",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tower-http 0.6.2",
|
"tower-http 0.6.2",
|
||||||
|
@ -1058,7 +1057,7 @@ dependencies = [
|
||||||
"http 1.2.0",
|
"http 1.2.0",
|
||||||
"mime",
|
"mime",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.4",
|
"thiserror 2.0.6",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1108,9 +1107,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.22"
|
version = "4.5.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "69371e34337c4c984bbe322360c2547210bf632eb2814bbe78a6e87a2935bd2b"
|
checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
@ -1118,9 +1117,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.22"
|
version = "4.5.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e24c1b4099818523236a8ca881d2b45db98dadfb4625cf6608c12069fcbbde1"
|
checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
|
@ -1142,9 +1141,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.7.3"
|
version = "0.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
|
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cmake"
|
name = "cmake"
|
||||||
|
@ -1564,9 +1563,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.2.0"
|
version = "2.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4"
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ff"
|
name = "ff"
|
||||||
|
@ -2056,7 +2055,7 @@ dependencies = [
|
||||||
"rustls 0.23.19",
|
"rustls 0.23.19",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls 0.26.0",
|
"tokio-rustls 0.26.1",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"webpki-roots",
|
"webpki-roots",
|
||||||
]
|
]
|
||||||
|
@ -2314,9 +2313,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.74"
|
version = "0.3.76"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705"
|
checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
@ -2891,7 +2890,7 @@ dependencies = [
|
||||||
"rustc-hash 2.1.0",
|
"rustc-hash 2.1.0",
|
||||||
"rustls 0.23.19",
|
"rustls 0.23.19",
|
||||||
"socket2",
|
"socket2",
|
||||||
"thiserror 2.0.4",
|
"thiserror 2.0.6",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
@ -2910,7 +2909,7 @@ dependencies = [
|
||||||
"rustls 0.23.19",
|
"rustls 0.23.19",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"slab",
|
"slab",
|
||||||
"thiserror 2.0.4",
|
"thiserror 2.0.6",
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
"tracing",
|
"tracing",
|
||||||
"web-time",
|
"web-time",
|
||||||
|
@ -3058,6 +3057,7 @@ dependencies = [
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"h2 0.4.7",
|
||||||
"http 1.2.0",
|
"http 1.2.0",
|
||||||
"http-body 1.0.1",
|
"http-body 1.0.1",
|
||||||
"http-body-util",
|
"http-body-util",
|
||||||
|
@ -3080,7 +3080,7 @@ dependencies = [
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"sync_wrapper 1.0.2",
|
"sync_wrapper 1.0.2",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls 0.26.0",
|
"tokio-rustls 0.26.1",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"url",
|
"url",
|
||||||
|
@ -4032,11 +4032,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.4"
|
version = "2.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490"
|
checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl 2.0.4",
|
"thiserror-impl 2.0.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4052,9 +4052,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.4"
|
version = "2.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061"
|
checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -4167,20 +4167,19 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-rustls"
|
name = "tokio-rustls"
|
||||||
version = "0.26.0"
|
version = "0.26.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
|
checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls 0.23.19",
|
"rustls 0.23.19",
|
||||||
"rustls-pki-types",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-stream"
|
name = "tokio-stream"
|
||||||
version = "0.1.16"
|
version = "0.1.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1"
|
checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
@ -4586,9 +4585,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.97"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c"
|
checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
@ -4597,13 +4596,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-backend"
|
name = "wasm-bindgen-backend"
|
||||||
version = "0.2.97"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd"
|
checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
|
@ -4612,9 +4610,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-futures"
|
name = "wasm-bindgen-futures"
|
||||||
version = "0.4.47"
|
version = "0.4.49"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d"
|
checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
@ -4625,9 +4623,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.97"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051"
|
checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
|
@ -4635,9 +4633,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.97"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d"
|
checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -4648,9 +4646,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.97"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49"
|
checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-streams"
|
name = "wasm-streams"
|
||||||
|
@ -4667,9 +4665,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.74"
|
version = "0.3.76"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c"
|
checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
|
|
@ -97,7 +97,12 @@ impl CaStore {
|
||||||
let string_id = lexicographic_base64::encode(id.to_be_bytes());
|
let string_id = lexicographic_base64::encode(id.to_be_bytes());
|
||||||
let source_fname = format!("temp/{string_id}");
|
let source_fname = format!("temp/{string_id}");
|
||||||
|
|
||||||
/*info!("Starting multipart upload {id}");
|
let mut buf = BytesMut::with_capacity(5_000_000);
|
||||||
|
reader.read_buf(&mut buf).await?;
|
||||||
|
let hasher = Arc::new(Mutex::new(Hasher::new()));
|
||||||
|
|
||||||
|
let hash = if buf.len() >= 5_000_000 {
|
||||||
|
info!("Starting multipart upload {id}");
|
||||||
let multipart_result = self
|
let multipart_result = self
|
||||||
.client
|
.client
|
||||||
.create_multipart_upload()
|
.create_multipart_upload()
|
||||||
|
@ -107,6 +112,8 @@ impl CaStore {
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("Creating multipart request for Request ID{id}"))?;
|
.with_context(|| format!("Creating multipart request for Request ID{id}"))?;
|
||||||
|
|
||||||
|
let mut reader = buf.chain(reader);
|
||||||
|
|
||||||
let mut buf = BytesMut::with_capacity(16 * 1024 * 1024); // 16MiB byte buffer for the file
|
let mut buf = BytesMut::with_capacity(16 * 1024 * 1024); // 16MiB byte buffer for the file
|
||||||
let hasher = Arc::new(Mutex::new(Hasher::new()));
|
let hasher = Arc::new(Mutex::new(Hasher::new()));
|
||||||
|
|
||||||
|
@ -163,11 +170,9 @@ impl CaStore {
|
||||||
.set_upload_id(multipart_result.upload_id)
|
.set_upload_id(multipart_result.upload_id)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.context("Completing multipart upload")?;*/
|
.context("Completing multipart upload")?;
|
||||||
|
hash
|
||||||
let hasher = Arc::new(Mutex::new(Hasher::new()));
|
} else {
|
||||||
let mut buf = Vec::new();
|
|
||||||
reader.read_to_end(&mut buf).await?;
|
|
||||||
let buf = Bytes::from(buf);
|
let buf = Bytes::from(buf);
|
||||||
let buf2 = buf.clone();
|
let buf2 = buf.clone();
|
||||||
let hasher2 = Arc::clone(&hasher);
|
let hasher2 = Arc::clone(&hasher);
|
||||||
|
@ -184,7 +189,8 @@ impl CaStore {
|
||||||
.await
|
.await
|
||||||
.context("Uploading file")?;
|
.context("Uploading file")?;
|
||||||
|
|
||||||
let hash = hasher.lock().await.finalize();
|
hasher.lock().await.finalize()
|
||||||
|
};
|
||||||
|
|
||||||
let target_fname = lexicographic_base64::encode(hash.as_bytes());
|
let target_fname = lexicographic_base64::encode(hash.as_bytes());
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,11 @@ dotenvy = "0.15.7"
|
||||||
eyre = "0.6.12"
|
eyre = "0.6.12"
|
||||||
mime = "0.3.17"
|
mime = "0.3.17"
|
||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
reqwest = { version = "0.12.9", default-features = false, features = ["rustls-tls", "stream"] }
|
reqwest = { version = "0.12.9", default-features = false, features = [
|
||||||
|
"http2",
|
||||||
|
"rustls-tls",
|
||||||
|
"stream",
|
||||||
|
] }
|
||||||
tokio = { version = "1.41.1", features = ["fs", "macros", "rt-multi-thread"] }
|
tokio = { version = "1.41.1", features = ["fs", "macros", "rt-multi-thread"] }
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = "0.3.19"
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
use std::{collections::HashSet, future::Future, path::Path, pin::Pin};
|
use std::{
|
||||||
|
collections::HashSet, future::Future, path::PathBuf, pin::Pin, sync::Arc, time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use chir_rs_http_api::{
|
use chir_rs_http_api::{
|
||||||
auth::{LoginRequest, PasetoToken, Scope},
|
auth::{LoginRequest, PasetoToken, Scope},
|
||||||
errors::APIError,
|
errors::APIError,
|
||||||
};
|
};
|
||||||
use clap::{arg, Parser, Subcommand};
|
use clap::{arg, Parser, Subcommand};
|
||||||
use eyre::{eyre, Context as _, OptionExt as _, Result};
|
use eyre::{eyre, Context as _, Result};
|
||||||
use mime_guess::{Mime, MimeGuess};
|
use mime_guess::MimeGuess;
|
||||||
use reqwest::Body;
|
use reqwest::Body;
|
||||||
use tokio::join;
|
use tokio::{sync::Mutex, task::JoinSet};
|
||||||
use tracing::instrument;
|
use tracing::{info, instrument};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[arg(short, long, default_value = "http://localhost:5621/")]
|
#[arg(short, long, default_value = "https://lotte.chir.rs/")]
|
||||||
url: String,
|
url: String,
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Command,
|
command: Command,
|
||||||
|
@ -42,14 +44,18 @@ enum Command {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn login(url: String, username: String, password: String) -> Result<()> {
|
async fn login(
|
||||||
|
client: Arc<reqwest::Client>,
|
||||||
|
url: String,
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
) -> Result<()> {
|
||||||
let request = LoginRequest {
|
let request = LoginRequest {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
scopes: HashSet::from([Scope::Full]),
|
scopes: HashSet::from([Scope::Full]),
|
||||||
};
|
};
|
||||||
let request = bincode::encode_to_vec(request, bincode::config::standard())?;
|
let request = bincode::encode_to_vec(request, bincode::config::standard())?;
|
||||||
let client = reqwest::Client::new();
|
|
||||||
let res = client
|
let res = client
|
||||||
.post(format!("{url}.api/auth/login"))
|
.post(format!("{url}.api/auth/login"))
|
||||||
.header("Content-Type", "application/x+bincode")
|
.header("Content-Type", "application/x+bincode")
|
||||||
|
@ -74,9 +80,13 @@ async fn login(url: String, username: String, password: String) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(source))]
|
#[instrument(skip(client))]
|
||||||
async fn upload(url: String, source: impl AsRef<Path>, dest: String) -> Result<()> {
|
async fn upload_inner(
|
||||||
let client = reqwest::Client::new();
|
client: Arc<reqwest::Client>,
|
||||||
|
url: String,
|
||||||
|
source: PathBuf,
|
||||||
|
dest: String,
|
||||||
|
) -> Result<bool> {
|
||||||
let token = std::env::var("CHIR_RS_TOKEN")?;
|
let token = std::env::var("CHIR_RS_TOKEN")?;
|
||||||
let file = tokio::fs::File::open(&source).await?;
|
let file = tokio::fs::File::open(&source).await?;
|
||||||
let res = client
|
let res = client
|
||||||
|
@ -92,17 +102,55 @@ async fn upload(url: String, source: impl AsRef<Path>, dest: String) -> Result<(
|
||||||
.body(Body::from(file))
|
.body(Body::from(file))
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
if !res.status().is_success() {
|
let status = res.status();
|
||||||
|
if status.is_client_error() {
|
||||||
let response = res.bytes().await?;
|
let response = res.bytes().await?;
|
||||||
let response: APIError =
|
let response: APIError =
|
||||||
bincode::decode_from_slice(&response, bincode::config::standard())?.0;
|
bincode::decode_from_slice(&response, bincode::config::standard())?.0;
|
||||||
Err(response).with_context(|| format!("Uploading to {dest}"))?;
|
Err(response).with_context(|| format!("Uploading to {dest}"))?;
|
||||||
|
} else if status.is_server_error() {
|
||||||
|
let response = res.bytes().await?;
|
||||||
|
let response: APIError =
|
||||||
|
bincode::decode_from_slice(&response, bincode::config::standard())?.0;
|
||||||
|
println!("Server error updating {dest}: {response:?}");
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
info!("Updated {dest}.");
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(client))]
|
||||||
|
async fn upload(
|
||||||
|
client: Arc<reqwest::Client>,
|
||||||
|
url: String,
|
||||||
|
source: PathBuf,
|
||||||
|
dest: String,
|
||||||
|
) -> Result<()> {
|
||||||
|
loop {
|
||||||
|
if upload_inner(
|
||||||
|
Arc::clone(&client),
|
||||||
|
url.clone(),
|
||||||
|
source.clone(),
|
||||||
|
dest.clone(),
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
println!("Uploading to {dest} failed. waiting 5s");
|
||||||
|
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(source))]
|
#[instrument(skip(client))]
|
||||||
async fn upload_dir(url: String, source: impl AsRef<Path>, dest: String) -> Result<()> {
|
async fn upload_dir(
|
||||||
|
client: Arc<reqwest::Client>,
|
||||||
|
futs: Arc<Mutex<JoinSet<Result<()>>>>,
|
||||||
|
url: String,
|
||||||
|
source: PathBuf,
|
||||||
|
dest: String,
|
||||||
|
) -> Result<()> {
|
||||||
let mut dir = tokio::fs::read_dir(source).await?;
|
let mut dir = tokio::fs::read_dir(source).await?;
|
||||||
while let Some(ent) = dir.next_entry().await? {
|
while let Some(ent) = dir.next_entry().await? {
|
||||||
let file_type = ent.file_type().await?;
|
let file_type = ent.file_type().await?;
|
||||||
|
@ -116,19 +164,39 @@ async fn upload_dir(url: String, source: impl AsRef<Path>, dest: String) -> Resu
|
||||||
format!("{dest}/{file_name_str}")
|
format!("{dest}/{file_name_str}")
|
||||||
};
|
};
|
||||||
if file_type.is_dir() {
|
if file_type.is_dir() {
|
||||||
let sub_fut: Pin<Box<dyn Future<Output = Result<()>>>> =
|
let boxed: Pin<Box<dyn Future<Output = Result<()>>>> = Box::pin(upload_dir(
|
||||||
Box::pin(upload_dir(url.clone(), ent.path(), tgt));
|
Arc::clone(&client),
|
||||||
sub_fut.await?;
|
Arc::clone(&futs),
|
||||||
|
url.clone(),
|
||||||
|
ent.path().to_path_buf(),
|
||||||
|
tgt,
|
||||||
|
));
|
||||||
|
boxed.await?;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if file_name_str == "index.html" {
|
if file_name_str == "index.html" {
|
||||||
if dest.is_empty() {
|
if !dest.is_empty() {
|
||||||
upload(url.clone(), ent.path(), "".to_string()).await?;
|
futs.lock().await.spawn(upload(
|
||||||
} else {
|
Arc::clone(&client),
|
||||||
upload(url.clone(), ent.path(), format!("{dest}/")).await?;
|
url.clone(),
|
||||||
|
ent.path().to_path_buf(),
|
||||||
|
format!("{dest}/"),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
futs.lock().await.spawn(upload(
|
||||||
|
Arc::clone(&client),
|
||||||
|
url.clone(),
|
||||||
|
ent.path().to_path_buf(),
|
||||||
|
dest.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
upload(url.clone(), ent.path(), tgt).await?;
|
futs.lock().await.spawn(upload(
|
||||||
|
Arc::clone(&client),
|
||||||
|
url.clone(),
|
||||||
|
ent.path().to_path_buf(),
|
||||||
|
tgt,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -139,11 +207,22 @@ async fn main() -> Result<()> {
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
let matches = Args::parse();
|
let matches = Args::parse();
|
||||||
|
let client = Arc::new(reqwest::Client::new());
|
||||||
|
|
||||||
match matches.command {
|
match matches.command {
|
||||||
Command::Login { username, password } => login(matches.url, username, password).await?,
|
Command::Login { username, password } => {
|
||||||
Command::Upload { source, dest } => upload(matches.url, source, dest).await?,
|
login(client, matches.url, username, password).await?
|
||||||
Command::UploadDir { source, dest } => upload_dir(matches.url, source, dest).await?,
|
}
|
||||||
|
Command::Upload { source, dest } => {
|
||||||
|
upload(client, matches.url, source.into(), dest).await?
|
||||||
|
}
|
||||||
|
Command::UploadDir { source, dest } => {
|
||||||
|
let futs = Arc::new(Mutex::new(JoinSet::new()));
|
||||||
|
upload_dir(client, Arc::clone(&futs), matches.url, source.into(), dest).await?;
|
||||||
|
while let Some(v) = futs.lock().await.join_next().await {
|
||||||
|
v??;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -19,7 +19,7 @@ use tracing::{error, info, instrument};
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub async fn expire(db: &Database) -> Result<()> {
|
pub async fn expire(db: &Database) -> Result<()> {
|
||||||
let id = id_generator::generate();
|
let id = id_generator::generate();
|
||||||
let oldest_acceptable_id = id - ((24 * 60 * 60) << 48);
|
let oldest_acceptable_id = id - ((24 * 60 * 60 * 1_000_000_000) << 48);
|
||||||
let oldest_acceptable_id = oldest_acceptable_id.to_be_bytes();
|
let oldest_acceptable_id = oldest_acceptable_id.to_be_bytes();
|
||||||
#[expect(clippy::panic, reason = "sqlx moment")]
|
#[expect(clippy::panic, reason = "sqlx moment")]
|
||||||
query!(
|
query!(
|
||||||
|
|
|
@ -22,9 +22,11 @@ chrono = "0.4.38"
|
||||||
eyre = "0.6.12"
|
eyre = "0.6.12"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
mime = "0.3.17"
|
mime = "0.3.17"
|
||||||
rusty_paseto = { version = "0.7.1", default-features = false, features = ["batteries_included", "v4_local"] }
|
rusty_paseto = { version = "0.7.1", default-features = false, features = [
|
||||||
|
"batteries_included",
|
||||||
|
"v4_local",
|
||||||
|
] }
|
||||||
sentry-tower = { version = "0.34.0", features = ["axum", "axum-matched-path"] }
|
sentry-tower = { version = "0.34.0", features = ["axum", "axum-matched-path"] }
|
||||||
serde = { version = "1.0.215", features = ["derive"] }
|
|
||||||
tokio = { version = "1.41.1", features = ["fs", "net"] }
|
tokio = { version = "1.41.1", features = ["fs", "net"] }
|
||||||
tokio-util = { version = "0.7.13", features = ["compat"] }
|
tokio-util = { version = "0.7.13", features = ["compat"] }
|
||||||
tower-http = { version = "0.6.2", features = ["trace"] }
|
tower-http = { version = "0.6.2", features = ["trace"] }
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
body::Body,
|
body::Body,
|
||||||
extract::{Query, State},
|
extract::State,
|
||||||
http::{
|
http::{
|
||||||
header::{ACCEPT, CACHE_CONTROL, CONTENT_LENGTH, CONTENT_TYPE, ETAG, IF_NONE_MATCH},
|
header::{ACCEPT, CACHE_CONTROL, CONTENT_LENGTH, CONTENT_TYPE, ETAG, IF_NONE_MATCH},
|
||||||
HeaderMap, Request, StatusCode, Uri,
|
HeaderMap, Request, StatusCode, Uri,
|
||||||
|
@ -15,7 +15,6 @@ use chir_rs_misc::lexicographic_base64;
|
||||||
use eyre::Context as _;
|
use eyre::Context as _;
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use mime::MimeIter;
|
use mime::MimeIter;
|
||||||
use serde::Deserialize;
|
|
||||||
use tokio_util::compat::FuturesAsyncReadCompatExt as _;
|
use tokio_util::compat::FuturesAsyncReadCompatExt as _;
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info};
|
||||||
|
|
||||||
|
|
12
flake.lock
12
flake.lock
|
@ -78,11 +78,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733132332,
|
"lastModified": 1733682815,
|
||||||
"narHash": "sha256-8DTh3irBPko0ooHaeGJ5kPwBD8mOwiMX4eBjFuicLsA=",
|
"narHash": "sha256-8DFHnrHprF8u95VOFgMAgJe2OBD70pd1g0NFtIEElAY=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "b9ffe0d2ef589f4d75a62f908f00dfd6344b6b6e",
|
"rev": "73b9f2d20bea97d5bd6c8158f3a388ef40ac97c5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -128,11 +128,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733106880,
|
"lastModified": 1733625333,
|
||||||
"narHash": "sha256-aJmAIjZfWfPSWSExwrYBLRgXVvgF5LP1vaeUGOOIQ98=",
|
"narHash": "sha256-tIML2axjm4AnlKP29upVJxzBpj4Cy4ak+PKonqQtXmc=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "e66c0d43abf5bdefb664c3583ca8994983c332ae",
|
"rev": "430c8b054e45ea44fd2c9521a378306ada507a6c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
Loading…
Reference in a new issue