Compare commits
2 commits
fada53044d
...
0efde0e134
| Author | SHA1 | Date | |
|---|---|---|---|
| 0efde0e134 | |||
| b9e553f112 |
6 changed files with 8 additions and 13 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -85,12 +85,6 @@ version = "0.22.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64ct"
|
|
||||||
version = "1.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.9.1"
|
version = "2.9.1"
|
||||||
|
|
@ -881,7 +875,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
name = "shrupl"
|
name = "shrupl"
|
||||||
version = "0.1.0-alpha"
|
version = "0.1.0-alpha"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64ct",
|
"base64",
|
||||||
"blake2b_simd",
|
"blake2b_simd",
|
||||||
"clap",
|
"clap",
|
||||||
"console",
|
"console",
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ edition = "2024"
|
||||||
description = "ShrUpl is a tool to upload files to a Sharry Instance through a public Alias, leveraging the tus protocol"
|
description = "ShrUpl is a tool to upload files to a Sharry Instance through a public Alias, leveraging the tus protocol"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64ct = { version = "1.8.0", default-features = false, features = ["alloc"] }
|
base64 = { version = "0.22.1", default-features = false }
|
||||||
blake2b_simd = "1.0.3"
|
blake2b_simd = "1.0.3"
|
||||||
clap = { version = "4.5.38", features = ["derive"] }
|
clap = { version = "4.5.38", features = ["derive"] }
|
||||||
console = { version = "0.15.11", default-features = false }
|
console = { version = "0.15.11", default-features = false }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{convert::Infallible, fmt, io, time::Duration};
|
use std::{convert::Infallible, fmt, io, time::Duration};
|
||||||
|
|
||||||
use base64ct::{Base64UrlUnpadded, Encoding};
|
use base64::{Engine, prelude::BASE64_URL_SAFE_NO_PAD as BASE64URL};
|
||||||
use blake2b_simd::Params as Blake2b;
|
use blake2b_simd::Params as Blake2b;
|
||||||
use clap::{Parser, builder::TypedValueParser, value_parser};
|
use clap::{Parser, builder::TypedValueParser, value_parser};
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
|
|
@ -153,6 +153,6 @@ impl Cli {
|
||||||
hasher.update(chk.as_ref());
|
hasher.update(chk.as_ref());
|
||||||
}
|
}
|
||||||
|
|
||||||
Base64UrlUnpadded::encode_string(hasher.finalize().as_bytes())
|
BASE64URL.encode(hasher.finalize())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ impl Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn get_invalid_param(&self) -> Option<&Parameter> {
|
pub fn get_invalid_param(&self) -> Option<&Parameter> {
|
||||||
if let Self::InvalidParameter(p) = self {
|
if let Self::InvalidParameter(p) = self {
|
||||||
Some(p)
|
Some(p)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ mod uploading;
|
||||||
|
|
||||||
use std::{ffi::OsStr, fs, io::Read, path::Path};
|
use std::{ffi::OsStr, fs, io::Read, path::Path};
|
||||||
|
|
||||||
use base64ct::{Base64, Encoding};
|
use base64::{Engine, prelude::BASE64_STANDARD_NO_PAD as BASE64};
|
||||||
use blake2b_simd::Params as Blake2b;
|
use blake2b_simd::Params as Blake2b;
|
||||||
|
|
||||||
pub use checked::Checked;
|
pub use checked::Checked;
|
||||||
|
|
@ -35,7 +35,7 @@ fn compute_file_hash(path: &Path, size: u64, on_progress: impl Fn(u64)) -> crate
|
||||||
return Err(crate::Error::mismatch(size, bytes_read));
|
return Err(crate::Error::mismatch(size, bytes_read));
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = Base64::encode_string(hasher.finalize().as_bytes());
|
let result = BASE64.encode(hasher.finalize());
|
||||||
debug!("hashed {:?}: {result:?}", path.display());
|
debug!("hashed {:?}: {result:?}", path.display());
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ impl From<String> for Uri {
|
||||||
SHARRY_URI_RE.captures(value).map(|caps| {
|
SHARRY_URI_RE.captures(value).map(|caps| {
|
||||||
let captured = |name| {
|
let captured = |name| {
|
||||||
caps.name(name)
|
caps.name(name)
|
||||||
.expect(&format!("{name} not captured"))
|
.unwrap_or_else(|| panic!("{name} not captured"))
|
||||||
.as_str()
|
.as_str()
|
||||||
.to_string()
|
.to_string()
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue