diff --git a/confetti-box/Cargo.toml b/confetti-box/Cargo.toml index d36d70e..52e8ec9 100644 --- a/confetti-box/Cargo.toml +++ b/confetti-box/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "confetti_box" -version = "0.1.3" +version = "0.2.0" repository = "https://github.com/Dangoware/confetti-box" license = "AGPL-3.0-or-later" authors.workspace = true @@ -10,19 +10,18 @@ edition = "2021" workspace = true [dependencies] -blake3 = { version = "1.5.4", features = ["mmap", "rayon", "serde"] } -chrono = { version = "0.4.38", features = ["serde"] } -ciborium = "0.2.2" +blake3 = { version = "1.5", features = ["mmap", "rayon", "serde"] } +chrono = { version = "0.4", features = ["serde"] } +ciborium = "0.2" file-format = { version = "0.26", features = ["reader"] } log = "0.4" -lz4_flex = "0.11.3" maud = { version = "0.26", features = ["rocket"] } -rand = "0.8.5" +rand = "0.8" rocket = { version = "0.5", features = ["json"] } -rocket_ws = "0.1.1" -serde = { version = "1.0.213", features = ["derive"] } -serde_with = { version = "3.11.0", features = ["chrono_0_4"] } -toml = "0.8.19" -unidecode = "0.3.0" -urlencoding = "2.1.3" -uuid = { version = "1.11.0", features = ["serde", "v4"] } +rocket_ws = "0.1" +serde = { version = "1.0", features = ["derive"] } +serde_with = { version = "3.11", features = ["chrono_0_4"] } +toml = "0.8" +unidecode = "0.3" +urlencoding = "2.1" +uuid = { version = "1.11", features = ["serde", "v4"] } diff --git a/confetti-box/src/database.rs b/confetti-box/src/database.rs index 69d95da..9dda827 100644 --- a/confetti-box/src/database.rs +++ b/confetti-box/src/database.rs @@ -2,7 +2,7 @@ use std::{ collections::{hash_map::Values, HashMap, HashSet}, ffi::OsStr, fs::{self, File}, - io, + io::{self, Write}, path::{Path, PathBuf}, sync::{Arc, RwLock}, }; @@ -48,10 +48,9 @@ impl Mochibase { /// Open the database from a path pub fn open>(path: &P) -> Result { - let file = File::open(path)?; - let mut lz4_file = lz4_flex::frame::FrameDecoder::new(file); + let mut file = File::open(path)?; - from_reader(&mut lz4_file) + from_reader(&mut file) .map_err(|e| io::Error::other(format!("failed to open database: {e}"))) } @@ -67,11 +66,10 @@ impl Mochibase { /// Save the database to its file pub fn save(&self) -> Result<(), io::Error> { // Create a file and write the LZ4 compressed stream into it - let file = File::create(self.path.with_extension("bkp"))?; - let mut lz4_file = lz4_flex::frame::FrameEncoder::new(file); - into_writer(self, &mut lz4_file) + let mut file = File::create(self.path.with_extension("bkp"))?; + into_writer(self, &mut file) .map_err(|e| io::Error::other(format!("failed to save database: {e}")))?; - lz4_file.try_finish()?; + file.flush()?; fs::rename(self.path.with_extension("bkp"), &self.path).unwrap(); diff --git a/confetti-box/src/pages.rs b/confetti-box/src/pages.rs index d58d024..7235996 100644 --- a/confetti-box/src/pages.rs +++ b/confetti-box/src/pages.rs @@ -19,11 +19,14 @@ pub fn head(page_title: &str) -> Markup { pub fn footer() -> Markup { html! { footer { - p {a href="/" {"Home"}} - p {a href="/about" {"About"}} - p {a href="/api" {"API"}} - p {a href="https://github.com/Dangoware/confetti-box" {"Source"}} - p {a href="https://github.com/Dangoware/" {"Dangoware"}} + div { + p {a href="/" {"Home"}} + p {a href="/about" {"About"}} + p {a href="/api" {"API"}} + p {a href="https://github.com/Dangoware/confetti-box" {"Source"}} + p {a href="https://github.com/Dangoware/" {"Dangoware"}} + } + p.version { "Running Confetti-Box v" (env!("CARGO_PKG_VERSION")) } } } } diff --git a/confetti-box/web/main.css b/confetti-box/web/main.css index 1873549..709daf0 100644 --- a/confetti-box/web/main.css +++ b/confetti-box/web/main.css @@ -24,16 +24,23 @@ center { } footer { - display: flex; - width: fit-content; + div { + display: flex; + width: fit-content; - p { - border-right: 2px dotted grey; - padding: 0 10px; + p { + border-right: 2px dotted grey; + padding: 0 10px; + } + + p:last-child { + border-right: none; + } } - p:last-child { - border-right: none; + p.version { + margin-top: 0; + opacity: 45%; } } diff --git a/confetti-box/web/request.js b/confetti-box/web/request.js index 0b3c9d2..f6754d5 100644 --- a/confetti-box/web/request.js +++ b/confetti-box/web/request.js @@ -206,7 +206,7 @@ async function uploadFileWebsocket(file, duration, maxSize) { new_uri = "ws:"; } new_uri += "//" + loc.host; - new_uri += loc.pathname + "/upload/websocket?name=" + file.name +"&size=" + file.size + "&duration=" + parseInt(duration); + new_uri += "/upload/websocket?name=" + file.name +"&size=" + file.size + "&duration=" + parseInt(duration); const socket = new WebSocket(new_uri); const chunkSize = 10_000_000;