Compare commits

...

4 Commits

Author SHA1 Message Date
spinline
2e36c28c0d fix(frontend): replace unwrap() with expect() for better error messages
All checks were successful
Build MIPS Binary / build (push) Successful in 4m13s
- console_log::init_with_level() now uses expect()
- web_sys::window() now uses expect() with helpful message
- window.document() now uses expect()
- document.body() now uses expect()

This provides meaningful error messages if WASM initialization fails.
2026-02-08 05:41:07 +03:00
spinline
6530e20af2 perf(db): enable SQLite WAL mode and performance settings
All checks were successful
Build MIPS Binary / build (push) Successful in 4m14s
- PRAGMA journal_mode=WAL - concurrent reads while writing
- PRAGMA synchronous=NORMAL - faster than FULL, still safe
- PRAGMA busy_timeout=5000 - reduces database locked errors

Note: Existing databases should be deleted to enable WAL mode properly.
2026-02-08 05:34:06 +03:00
spinline
32f4946530 fix: show N/A for magnet link dates
All checks were successful
Build MIPS Binary / build (push) Successful in 4m14s
Magnet links don't have creation_date, so timestamp is 0.
Now shows 'N/A' instead of 01/01/1970 00:00
2026-02-08 05:28:14 +03:00
spinline
619951fa1c security: remove hardcoded VAPID keys fallback
All checks were successful
Build MIPS Binary / build (push) Successful in 4m14s
VAPID keys must now be set via environment variables or .env file.
This eliminates the security risk of having keys in source code.
2026-02-08 05:16:31 +03:00
4 changed files with 29 additions and 13 deletions

View File

@@ -21,6 +21,21 @@ impl Db {
} }
async fn run_migrations(&self) -> Result<()> { async fn run_migrations(&self) -> Result<()> {
// WAL mode - enables concurrent reads while writing
sqlx::query("PRAGMA journal_mode=WAL")
.execute(&self.pool)
.await?;
// NORMAL synchronous - faster than FULL, still safe enough
sqlx::query("PRAGMA synchronous=NORMAL")
.execute(&self.pool)
.await?;
// 5 second busy timeout - reduces "database locked" errors
sqlx::query("PRAGMA busy_timeout=5000")
.execute(&self.pool)
.await?;
sqlx::migrate!("./migrations").run(&self.pool).await?; sqlx::migrate!("./migrations").run(&self.pool).await?;
Ok(()) Ok(())
} }

View File

@@ -118,13 +118,8 @@ pub async fn send_push_notification(
let client = HyperWebPushClient::new(); let client = HyperWebPushClient::new();
// Get VAPID keys from environment or use defaults let vapid_private_key = std::env::var("VAPID_PRIVATE_KEY").expect("VAPID_PRIVATE_KEY must be set in .env");
let _vapid_public_key = std::env::var("VAPID_PUBLIC_KEY") let vapid_email = std::env::var("VAPID_EMAIL").expect("VAPID_EMAIL must be set in .env");
.unwrap_or_else(|_| "BEdPj6XQR7MGzM28Nev9wokF5upHoydNDahouJbQ9ZdBJpEFAN1iNfANSEvY0ItasNY5zcvvqN_tjUt64Rfd0gU".to_string());
let vapid_private_key = std::env::var("VAPID_PRIVATE_KEY")
.unwrap_or_else(|_| "aUcCYJ7kUd9UClCaWwad0IVgbYJ6svwl19MjSX7GH10".to_string());
let vapid_email = std::env::var("VAPID_EMAIL")
.unwrap_or_else(|_| "mailto:admin@vibetorrent.app".to_string());
for subscription in subscriptions { for subscription in subscriptions {
let subscription_info = SubscriptionInfo { let subscription_info = SubscriptionInfo {
@@ -166,6 +161,5 @@ pub async fn send_push_notification(
} }
pub fn get_vapid_public_key() -> String { pub fn get_vapid_public_key() -> String {
std::env::var("VAPID_PUBLIC_KEY") std::env::var("VAPID_PUBLIC_KEY").expect("VAPID_PUBLIC_KEY must be set in .env")
.unwrap_or_else(|_| "BEdPj6XQR7MGzM28Nev9wokF5upHoydNDahouJbQ9ZdBJpEFAN1iNfANSEvY0ItasNY5zcvvqN_tjUt64Rfd0gU".to_string())
} }

View File

@@ -46,6 +46,9 @@ fn format_duration(seconds: i64) -> String {
} }
fn format_date(timestamp: i64) -> String { fn format_date(timestamp: i64) -> String {
if timestamp <= 0 {
return "N/A".to_string();
}
let dt = chrono::DateTime::from_timestamp(timestamp, 0); let dt = chrono::DateTime::from_timestamp(timestamp, 0);
match dt { match dt {
Some(dt) => dt.format("%d/%m/%Y %H:%M").to_string(), Some(dt) => dt.format("%d/%m/%Y %H:%M").to_string(),

View File

@@ -11,11 +11,15 @@ use app::App;
#[wasm_bindgen(start)] #[wasm_bindgen(start)]
pub fn main() { pub fn main() {
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();
console_log::init_with_level(log::Level::Debug).unwrap(); console_log::init_with_level(log::Level::Debug)
.expect("Failed to initialize logging");
let window = web_sys::window().unwrap(); let window = web_sys::window()
let document = window.document().unwrap(); .expect("Failed to access window - browser may not be fully loaded");
let body = document.body().unwrap(); let document = window.document()
.expect("Failed to access document");
let body = document.body()
.expect("Failed to access document body");
// Add app-loaded class to body to hide spinner via CSS // Add app-loaded class to body to hide spinner via CSS
let _ = body.class_list().add_1("app-loaded"); let _ = body.class_list().add_1("app-loaded");