diff --git a/build.rs b/build.rs index 27740cf4..d653cc82 100644 --- a/build.rs +++ b/build.rs @@ -132,8 +132,12 @@ fn process_release(manifest_dir: &Path, static_dir: &Path, out_dir: &Path) { let theme_init = fs::read_to_string(static_dir.join("js/core/theme-init.js")).unwrap_or_default(); let theme_init_min = js_minify_safe(&theme_init); - let rewritten_index = - rewrite_index_html(&index_html, &format!("/css/{css_name}"), &format!("/js/{js_name}"), &theme_init_min); + let rewritten_index = rewrite_index_html( + &index_html, + &format!("/css/{css_name}"), + &format!("/js/{js_name}"), + &theme_init_min, + ); fs::write(dist_dir.join("index.html"), &rewritten_index).expect("write dist index.html"); // ── 8. Minify locale JSONs ─────────────────────────────────────────────── @@ -301,7 +305,11 @@ fn build_js_module_bundle(entry_scripts: &[String], static_dir: &Path) -> String /// DFS post-order: push `file` to `order` after all its imports. /// Marks files as seen before recursing to break circular dependencies. -fn collect_module_deps(file: &Path, order: &mut Vec, seen: &mut std::collections::HashSet) { +fn collect_module_deps( + file: &Path, + order: &mut Vec, + seen: &mut std::collections::HashSet, +) { let canonical = match file.canonicalize() { Ok(p) => p, Err(_) => { @@ -437,9 +445,8 @@ fn strip_esm_syntax(source: &str) -> String { // ── export default expr ──────────────────────────────────────────────── // Rare in our codebase; keep the value as a named variable. - if t.starts_with("export default ") { + if let Some(rhs) = t.strip_prefix("export default ") { let indent = &line[..line.len() - line.trim_start().len()]; - let rhs = &t["export default ".len()..]; out.push_str(&format!("{indent}const _default = {rhs}")); out.push('\n'); continue; @@ -468,7 +475,11 @@ fn try_strip_export_prefix(line: &str) -> Option { if t.starts_with(prefix) { let indent_len = line.len() - line.trim_start().len(); // Remove "export " (7 chars) right after the indent - return Some(format!("{}{}", &line[..indent_len], &line[indent_len + 7..])); + return Some(format!( + "{}{}", + &line[..indent_len], + &line[indent_len + 7..] + )); } } None @@ -534,7 +545,11 @@ fn js_minify(source: &str, is_module: bool) -> Result { use oxc_span::SourceType; let allocator = Allocator::default(); - let source_type = if is_module { SourceType::mjs() } else { SourceType::cjs() }; + let source_type = if is_module { + SourceType::mjs() + } else { + SourceType::cjs() + }; let ret = Parser::new(&allocator, source, source_type).parse(); if !ret.errors.is_empty() { @@ -556,7 +571,11 @@ fn js_minify(source: &str, is_module: bool) -> Result { let output = Codegen::new() .with_options(CodegenOptions { minify: true, - comments: CommentOptions { normal: false, jsdoc: false, ..CommentOptions::default() }, + comments: CommentOptions { + normal: false, + jsdoc: false, + ..CommentOptions::default() + }, ..Default::default() }) .build(&program); @@ -670,7 +689,9 @@ fn rewrite_index_html(html: &str, css_path: &str, js_path: &str, inline_theme_js // ── Replace all type="module" scripts with single bundle ───────────── if t.starts_with("")); + out.push(format!( + " " + )); js_done = true; } continue; diff --git a/src/infrastructure/services/audio_metadata_service.rs b/src/infrastructure/services/audio_metadata_service.rs index b162c457..303b2e6a 100644 --- a/src/infrastructure/services/audio_metadata_service.rs +++ b/src/infrastructure/services/audio_metadata_service.rs @@ -60,9 +60,7 @@ impl AudioMetadataService { /// /// All I/O is synchronous (id3 + mp3_duration crates), so this MUST /// only be called inside `spawn_blocking`. - fn extract_metadata_blocking( - file_path: &Path, - ) -> Option { + fn extract_metadata_blocking(file_path: &Path) -> Option { if !file_path.exists() { warn!("File does not exist: {:?}", file_path); return None; @@ -114,13 +112,14 @@ impl AudioMetadataService { // ── Sync I/O on the blocking thread pool (never stalls Tokio workers) ── let path = file_path.to_path_buf(); - let metadata = tokio::task::spawn_blocking(move || { - Self::extract_metadata_blocking(&path) - }) - .await - .map_err(|e| { - DomainError::internal_error("AudioMetadataService", format!("spawn_blocking join error: {e}")) - })?; + let metadata = tokio::task::spawn_blocking(move || Self::extract_metadata_blocking(&path)) + .await + .map_err(|e| { + DomainError::internal_error( + "AudioMetadataService", + format!("spawn_blocking join error: {e}"), + ) + })?; let Some(m) = metadata else { return Ok(()); diff --git a/src/infrastructure/services/dedup_service.rs b/src/infrastructure/services/dedup_service.rs index a60ce7f8..34dc96e5 100644 --- a/src/infrastructure/services/dedup_service.rs +++ b/src/infrastructure/services/dedup_service.rs @@ -717,7 +717,11 @@ impl DedupService { // Also clean up any thumbnail files for these blob hashes // (thumbnails are keyed by blob_hash and live under // storage_root/.thumbnails/{icon,preview,large}/{hash}.jpg). - let thumbnails_root = self.blob_root.parent().unwrap_or(&self.blob_root).join(".thumbnails"); + let thumbnails_root = self + .blob_root + .parent() + .unwrap_or(&self.blob_root) + .join(".thumbnails"); for (hash, size) in &batch { let blob_path = self.blob_path(hash); if let Err(e) = fs::remove_file(&blob_path).await { diff --git a/src/infrastructure/services/thumbnail_service_test.rs b/src/infrastructure/services/thumbnail_service_test.rs index 807fdd41..adaf31db 100644 --- a/src/infrastructure/services/thumbnail_service_test.rs +++ b/src/infrastructure/services/thumbnail_service_test.rs @@ -40,7 +40,12 @@ async fn generate_thumbnail_from_blob_path() { // The key assertion: the service can read from a blob path (not a logical path) let result = svc - .get_thumbnail("test-file-id", "ab1234567890", ThumbnailSize::Icon, &blob_path) + .get_thumbnail( + "test-file-id", + "ab1234567890", + ThumbnailSize::Icon, + &blob_path, + ) .await; let thumb_bytes = result.expect("thumbnail generation should succeed from blob path"); @@ -67,7 +72,12 @@ async fn generate_thumbnail_nonexistent_path_returns_error() { let bad_path = tmp.path().join("does-not-exist.png"); let result = svc - .get_thumbnail("missing-id", "nonexistent-hash", ThumbnailSize::Icon, &bad_path) + .get_thumbnail( + "missing-id", + "nonexistent-hash", + ThumbnailSize::Icon, + &bad_path, + ) .await; assert!(result.is_err(), "should fail for nonexistent file"); diff --git a/src/interfaces/api/handlers/file_handler.rs b/src/interfaces/api/handlers/file_handler.rs index 6686a464..599b3d1d 100644 --- a/src/interfaces/api/handlers/file_handler.rs +++ b/src/interfaces/api/handlers/file_handler.rs @@ -746,7 +746,11 @@ impl FileHandler { tokio::spawn(async move { tracing::info!("🖼️ Generating thumbnails for: {}", file_id); - thumbnail_service.generate_all_sizes_background(file_id, blob_hash_owned, file_path); + thumbnail_service.generate_all_sizes_background( + file_id, + blob_hash_owned, + file_path, + ); }); } diff --git a/src/interfaces/api/handlers/share_handler.rs b/src/interfaces/api/handlers/share_handler.rs index 0b732583..e76a9af7 100644 --- a/src/interfaces/api/handlers/share_handler.rs +++ b/src/interfaces/api/handlers/share_handler.rs @@ -16,7 +16,10 @@ use crate::application::services::share_service::ShareService; use crate::{ application::{ dtos::share_dto::{CreateShareDto, UpdateShareDto}, - ports::{file_ports::{FileRetrievalUseCase, OptimizedFileContent}, share_ports::ShareUseCase}, + ports::{ + file_ports::{FileRetrievalUseCase, OptimizedFileContent}, + share_ports::ShareUseCase, + }, }, common::{di::AppState, errors::ErrorKind}, domain::entities::share::ShareItemType, @@ -290,7 +293,7 @@ pub async fn download_shared_file( "Sharing is disabled", "Disabled", ) - .into_response() + .into_response(); } }; diff --git a/src/interfaces/middleware/auth.rs b/src/interfaces/middleware/auth.rs index 149eb8e7..1b592289 100644 --- a/src/interfaces/middleware/auth.rs +++ b/src/interfaces/middleware/auth.rs @@ -243,10 +243,7 @@ pub async fn auth_middleware( if request.uri().path().starts_with("/webdav") { return Ok(Response::builder() .status(StatusCode::UNAUTHORIZED) - .header( - header::WWW_AUTHENTICATE, - r#"Basic realm="OxiCloud""#, - ) + .header(header::WWW_AUTHENTICATE, r#"Basic realm="OxiCloud""#) .header(header::CONTENT_TYPE, "text/plain; charset=utf-8") .body(axum::body::Body::from( "Invalid username or app password",