Compare commits

..

No commits in common. "0efde0e134fe1254c567620564af3e9749c6e768" and "fada53044dc0a5630010c6a4aa4d2c01c1f4c9fc" have entirely different histories.

6 changed files with 13 additions and 8 deletions

8
Cargo.lock generated
View file

@ -85,6 +85,12 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "base64ct"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
[[package]]
name = "bitflags"
version = "2.9.1"
@ -875,7 +881,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
name = "shrupl"
version = "0.1.0-alpha"
dependencies = [
"base64",
"base64ct",
"blake2b_simd",
"clap",
"console",

View file

@ -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"
[dependencies]
base64 = { version = "0.22.1", default-features = false }
base64ct = { version = "1.8.0", default-features = false, features = ["alloc"] }
blake2b_simd = "1.0.3"
clap = { version = "4.5.38", features = ["derive"] }
console = { version = "0.15.11", default-features = false }

View file

@ -1,6 +1,6 @@
use std::{convert::Infallible, fmt, io, time::Duration};
use base64::{Engine, prelude::BASE64_URL_SAFE_NO_PAD as BASE64URL};
use base64ct::{Base64UrlUnpadded, Encoding};
use blake2b_simd::Params as Blake2b;
use clap::{Parser, builder::TypedValueParser, value_parser};
use log::LevelFilter;
@ -153,6 +153,6 @@ impl Cli {
hasher.update(chk.as_ref());
}
BASE64URL.encode(hasher.finalize())
Base64UrlUnpadded::encode_string(hasher.finalize().as_bytes())
}
}

View file

@ -121,7 +121,6 @@ impl Error {
}
}
#[must_use]
pub fn get_invalid_param(&self) -> Option<&Parameter> {
if let Self::InvalidParameter(p) = self {
Some(p)

View file

@ -4,7 +4,7 @@ mod uploading;
use std::{ffi::OsStr, fs, io::Read, path::Path};
use base64::{Engine, prelude::BASE64_STANDARD_NO_PAD as BASE64};
use base64ct::{Base64, Encoding};
use blake2b_simd::Params as Blake2b;
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));
}
let result = BASE64.encode(hasher.finalize());
let result = Base64::encode_string(hasher.finalize().as_bytes());
debug!("hashed {:?}: {result:?}", path.display());
Ok(result)
}

View file

@ -37,7 +37,7 @@ impl From<String> for Uri {
SHARRY_URI_RE.captures(value).map(|caps| {
let captured = |name| {
caps.name(name)
.unwrap_or_else(|| panic!("{name} not captured"))
.expect(&format!("{name} not captured"))
.as_str()
.to_string()
};