This commit is contained in:
xenofem 2025-09-25 01:06:43 -04:00
parent 2d580d2b78
commit cecb0e3db3
5 changed files with 953 additions and 778 deletions

1689
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -15,14 +15,14 @@ actix-web-actors = "4.1.0"
argon2 = "0.4.1" argon2 = "0.4.1"
askama = "0.11.1" askama = "0.11.1"
askama_actix = "0.13" askama_actix = "0.13"
base64 = "0.13" base64 = "0.22"
bytes = "1.1.0" bytes = "1.1.0"
bytesize = "1.1.0" bytesize = "2"
crc32fast = "1.3.2" crc32fast = "1.3.2"
dotenvy = "0.15" dotenvy = "0.15"
env_logger = "0.11.3" env_logger = "0.11.3"
futures-core = "0.3" futures-core = "0.3"
inotify = "0.10" inotify = "0.11"
jsondb = "0.4.0" jsondb = "0.4.0"
libc = "0.2" libc = "0.2"
log = "0.4" log = "0.4"
@ -34,8 +34,8 @@ rand = "0.8.5"
sanitise-file-name = "1.0.0" sanitise-file-name = "1.0.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
serde_with = { version = "2", features = ["time_0_3"] } serde_with = { version = "3", features = ["time_0_3"] }
thiserror = "1" thiserror = "2"
time = "0.3.9" time = "0.3.9"
tokio = { version = "1.17.0", features = ["full"] } tokio = { version = "1.17.0", features = ["full"] }
unicode-normalization = "0.1.19" unicode-normalization = "0.1.19"

View file

@ -290,12 +290,13 @@ pub(crate) fn new_live_reader(
file: File, file: File,
storage_path: PathBuf, storage_path: PathBuf,
) -> impl Stream<Item = Result<Bytes, Error>> { ) -> impl Stream<Item = Result<Bytes, Error>> {
let mut inotify = Inotify::init().expect("failed to init inotify"); let inotify = Inotify::init().expect("failed to init inotify");
inotify inotify
.add_watch(storage_path, WatchMask::MODIFY | WatchMask::CLOSE_WRITE) .watches()
.add(storage_path, WatchMask::MODIFY | WatchMask::CLOSE_WRITE)
.expect("Failed to add inotify watch"); .expect("Failed to add inotify watch");
let events = inotify let events = inotify
.event_stream([0; 1024]) .into_event_stream([0; 1024])
.expect("failed to set up event stream"); .expect("failed to set up event stream");
LiveFileReader { LiveFileReader {
size, size,

View file

@ -15,6 +15,7 @@ use actix_web::{
use actix_web_actors::ws; use actix_web_actors::ws;
use argon2::{Argon2, PasswordVerifier}; use argon2::{Argon2, PasswordVerifier};
use askama_actix::{Template, TemplateToResponse}; use askama_actix::{Template, TemplateToResponse};
use base64::prelude::*;
use bytesize::ByteSize; use bytesize::ByteSize;
use log::{error, warn}; use log::{error, warn};
use password_hash::PasswordHashString; use password_hash::PasswordHashString;
@ -395,13 +396,16 @@ async fn main() -> std::io::Result<()> {
let admin_password_hash: PasswordHashString = env_or_panic("TRANSBEAM_ADMIN_PASSWORD_HASH"); let admin_password_hash: PasswordHashString = env_or_panic("TRANSBEAM_ADMIN_PASSWORD_HASH");
let cookie_secret_base64: String = env_or_panic("TRANSBEAM_COOKIE_SECRET"); let cookie_secret_base64: String = env_or_panic("TRANSBEAM_COOKIE_SECRET");
let cookie_key = let cookie_key = cookie::Key::from(
cookie::Key::from(&base64::decode(&cookie_secret_base64).unwrap_or_else(|_| { &BASE64_STANDARD
panic!( .decode(&cookie_secret_base64)
"Value {} for TRANSBEAM_COOKIE_SECRET is not valid base64", .unwrap_or_else(|_| {
cookie_secret_base64 panic!(
) "Value {} for TRANSBEAM_COOKIE_SECRET is not valid base64",
})); cookie_secret_base64
)
}),
);
let state_file: PathBuf = match std::env::var("TRANSBEAM_STATE_FILE") { let state_file: PathBuf = match std::env::var("TRANSBEAM_STATE_FILE") {
Ok(v) => v Ok(v) => v

View file

@ -3,6 +3,7 @@ use jsondb::JsonDb;
pub mod prelude { pub mod prelude {
pub use std::collections::HashMap; pub use std::collections::HashMap;
use bytesize::ByteSize;
pub use jsondb::Schema; pub use jsondb::Schema;
pub use serde::{Deserialize, Serialize}; pub use serde::{Deserialize, Serialize};
pub use serde_with::serde_as; pub use serde_with::serde_as;
@ -13,7 +14,11 @@ pub mod prelude {
fn size(&self) -> u64; fn size(&self) -> u64;
fn formatted_size(&self) -> String { fn formatted_size(&self) -> String {
bytesize::to_string(self.size(), false).replace(' ', "") ByteSize(self.size())
.display()
.si()
.to_string()
.replace(' ', "")
} }
} }
} }