refactor(server): apply fmt + lint recos
This commit is contained in:
@@ -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<AudioMetadataFields> {
|
||||
fn extract_metadata_blocking(file_path: &Path) -> Option<AudioMetadataFields> {
|
||||
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(());
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user