Merge pull request #240 from EdouardVanbelle/style/format+clippy

This commit is contained in:
Dionisio Pozo
2026-03-28 19:05:16 +01:00
committed by GitHub
6 changed files with 60 additions and 54 deletions
@@ -7,9 +7,11 @@
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use crate::application::services::batch_operations::{BatchOperationService, BatchResult, BatchStats}; use crate::application::services::batch_operations::{
use crate::application::services::file_retrieval_service::FileRetrievalService; BatchOperationService, BatchResult, BatchStats,
};
use crate::application::services::file_management_service::FileManagementService; use crate::application::services::file_management_service::FileManagementService;
use crate::application::services::file_retrieval_service::FileRetrievalService;
use crate::application::services::folder_service::FolderService; use crate::application::services::folder_service::FolderService;
use crate::common::config::AppConfig; use crate::common::config::AppConfig;
use crate::infrastructure::repositories::pg::file_blob_read_repository::FileBlobReadRepository; use crate::infrastructure::repositories::pg::file_blob_read_repository::FileBlobReadRepository;
@@ -27,7 +29,11 @@ mod tests {
let mapped = trash_result.map(|_| id_for_result); let mapped = trash_result.map(|_| id_for_result);
assert!(mapped.is_ok(), "Ok result should remain Ok after mapping"); assert!(mapped.is_ok(), "Ok result should remain Ok after mapping");
assert_eq!(mapped.unwrap(), folder_id, "Mapped result should contain the folder_id"); assert_eq!(
mapped.unwrap(),
folder_id,
"Mapped result should contain the folder_id"
);
// Test Err maps to Err (preserved) // Test Err maps to Err (preserved)
let folder_id2 = "test-folder-id-2".to_string(); let folder_id2 = "test-folder-id-2".to_string();
@@ -35,7 +41,10 @@ mod tests {
let id_for_result2 = folder_id2.clone(); let id_for_result2 = folder_id2.clone();
let mapped2 = trash_result2.map(|_| id_for_result2); let mapped2 = trash_result2.map(|_| id_for_result2);
assert!(mapped2.is_err(), "Err result should remain Err after mapping"); assert!(
mapped2.is_err(),
"Err result should remain Err after mapping"
);
} }
/// Test that batch result counting works correctly /// Test that batch result counting works correctly
@@ -65,7 +74,11 @@ mod tests {
assert_eq!(result.stats.successful, 2, "Should have 2 successful"); assert_eq!(result.stats.successful, 2, "Should have 2 successful");
assert_eq!(result.stats.failed, 1, "Should have 1 failed"); assert_eq!(result.stats.failed, 1, "Should have 1 failed");
assert_eq!(result.successful.len(), 2, "Successful vector should have 2 items"); assert_eq!(
result.successful.len(),
2,
"Successful vector should have 2 items"
);
assert_eq!(result.failed.len(), 1, "Failed vector should have 1 item"); assert_eq!(result.failed.len(), 1, "Failed vector should have 1 item");
} }
@@ -139,7 +139,8 @@ impl FileManagementUseCase for FileManagementService {
// Verify file ownership first // Verify file ownership first
self.verify_owner(file_id, caller_id).await?; self.verify_owner(file_id, caller_id).await?;
// Verify target folder ownership (prevents file from "disappearing") // Verify target folder ownership (prevents file from "disappearing")
self.verify_target_folder_owner(&folder_id, caller_id).await?; self.verify_target_folder_owner(&folder_id, caller_id)
.await?;
self.move_file(file_id, folder_id).await self.move_file(file_id, folder_id).await
} }
+1 -6
View File
@@ -333,12 +333,7 @@ mod tests {
#[test] #[test]
fn test_init_bad_color_1() { fn test_init_bad_color_1() {
let owner_id = Uuid::new_v4(); let owner_id = Uuid::new_v4();
let res = Calendar::new( let res = Calendar::new("Name".to_string(), owner_id, None, Some("foo".to_string()));
"Name".to_string(),
owner_id,
None,
Some("foo".to_string()),
);
assert!(res.is_err()); assert!(res.is_err());
} }
@@ -922,8 +922,8 @@ async fn handle_put(
let hash = hasher.finalize().to_hex().to_string(); let hash = hasher.finalize().to_hex().to_string();
// ── Quota enforcement ──────────────────────────────────── // ── Quota enforcement ────────────────────────────────────
if let Some(storage_svc) = state.storage_usage_service.as_ref() { if let Some(storage_svc) = state.storage_usage_service.as_ref()
if let Err(err) = storage_svc && let Err(err) = storage_svc
.check_storage_quota(user.id, total_bytes as u64) .check_storage_quota(user.id, total_bytes as u64)
.await .await
{ {
@@ -940,7 +940,6 @@ async fn handle_put(
"QuotaExceeded", "QuotaExceeded",
)); ));
} }
}
// ── Atomic store: temp file → dedup blob + DB metadata update ── // ── Atomic store: temp file → dedup blob + DB metadata update ──
let result = file_upload_service let result = file_upload_service
+2 -4
View File
@@ -15,8 +15,7 @@ pub fn create_web_routes() -> Router<Arc<AppState>> {
// XXX do we prefer PROFILE or ENV ? // XXX do we prefer PROFILE or ENV ?
let is_dev = std::env::var("PROFILE").is_ok_and(|profile| profile == "dev"); let is_dev = std::env::var("PROFILE").is_ok_and(|profile| profile == "dev");
let assets_dir = let assets_dir = if is_dev {
if is_dev {
// take directly the source (permits faster development) // take directly the source (permits faster development)
"static" "static"
} else { } else {
@@ -48,8 +47,7 @@ pub fn create_web_routes() -> Router<Arc<AppState>> {
let static_service = ServeDir::new(&static_path); let static_service = ServeDir::new(&static_path);
// By default assets are cached in release/production environement and no cache in dev // By default assets are cached in release/production environement and no cache in dev
let cache_control_value = let cache_control_value = if is_dev {
if is_dev {
"max-age=0, no-cache, no-store" "max-age=0, no-cache, no-store"
} else { } else {
"public, max-age=604800, stale-while-revalidate=86400" "public, max-age=604800, stale-while-revalidate=86400"