updates
This commit is contained in:
parent
2d580d2b78
commit
cecb0e3db3
5 changed files with 953 additions and 778 deletions
1689
Cargo.lock
generated
1689
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
10
Cargo.toml
10
Cargo.toml
|
@ -15,14 +15,14 @@ actix-web-actors = "4.1.0"
|
|||
argon2 = "0.4.1"
|
||||
askama = "0.11.1"
|
||||
askama_actix = "0.13"
|
||||
base64 = "0.13"
|
||||
base64 = "0.22"
|
||||
bytes = "1.1.0"
|
||||
bytesize = "1.1.0"
|
||||
bytesize = "2"
|
||||
crc32fast = "1.3.2"
|
||||
dotenvy = "0.15"
|
||||
env_logger = "0.11.3"
|
||||
futures-core = "0.3"
|
||||
inotify = "0.10"
|
||||
inotify = "0.11"
|
||||
jsondb = "0.4.0"
|
||||
libc = "0.2"
|
||||
log = "0.4"
|
||||
|
@ -34,8 +34,8 @@ rand = "0.8.5"
|
|||
sanitise-file-name = "1.0.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_with = { version = "2", features = ["time_0_3"] }
|
||||
thiserror = "1"
|
||||
serde_with = { version = "3", features = ["time_0_3"] }
|
||||
thiserror = "2"
|
||||
time = "0.3.9"
|
||||
tokio = { version = "1.17.0", features = ["full"] }
|
||||
unicode-normalization = "0.1.19"
|
||||
|
|
|
@ -290,12 +290,13 @@ pub(crate) fn new_live_reader(
|
|||
file: File,
|
||||
storage_path: PathBuf,
|
||||
) -> 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
|
||||
.add_watch(storage_path, WatchMask::MODIFY | WatchMask::CLOSE_WRITE)
|
||||
.watches()
|
||||
.add(storage_path, WatchMask::MODIFY | WatchMask::CLOSE_WRITE)
|
||||
.expect("Failed to add inotify watch");
|
||||
let events = inotify
|
||||
.event_stream([0; 1024])
|
||||
.into_event_stream([0; 1024])
|
||||
.expect("failed to set up event stream");
|
||||
LiveFileReader {
|
||||
size,
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -15,6 +15,7 @@ use actix_web::{
|
|||
use actix_web_actors::ws;
|
||||
use argon2::{Argon2, PasswordVerifier};
|
||||
use askama_actix::{Template, TemplateToResponse};
|
||||
use base64::prelude::*;
|
||||
use bytesize::ByteSize;
|
||||
use log::{error, warn};
|
||||
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 cookie_secret_base64: String = env_or_panic("TRANSBEAM_COOKIE_SECRET");
|
||||
let cookie_key =
|
||||
cookie::Key::from(&base64::decode(&cookie_secret_base64).unwrap_or_else(|_| {
|
||||
let cookie_key = cookie::Key::from(
|
||||
&BASE64_STANDARD
|
||||
.decode(&cookie_secret_base64)
|
||||
.unwrap_or_else(|_| {
|
||||
panic!(
|
||||
"Value {} for TRANSBEAM_COOKIE_SECRET is not valid base64",
|
||||
cookie_secret_base64
|
||||
)
|
||||
}));
|
||||
}),
|
||||
);
|
||||
|
||||
let state_file: PathBuf = match std::env::var("TRANSBEAM_STATE_FILE") {
|
||||
Ok(v) => v
|
||||
|
|
|
@ -3,6 +3,7 @@ use jsondb::JsonDb;
|
|||
pub mod prelude {
|
||||
pub use std::collections::HashMap;
|
||||
|
||||
use bytesize::ByteSize;
|
||||
pub use jsondb::Schema;
|
||||
pub use serde::{Deserialize, Serialize};
|
||||
pub use serde_with::serde_as;
|
||||
|
@ -13,7 +14,11 @@ pub mod prelude {
|
|||
fn size(&self) -> u64;
|
||||
|
||||
fn formatted_size(&self) -> String {
|
||||
bytesize::to_string(self.size(), false).replace(' ', "")
|
||||
ByteSize(self.size())
|
||||
.display()
|
||||
.si()
|
||||
.to_string()
|
||||
.replace(' ', "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue