fix(thumbnail): add timeout protection for large image processing

Resolves conflict between main and PR #229 by applying timeout support
on top of main's drop(data) memory optimization. Changes:
- Add thumbnail_generation_ms to TimeoutConfig (default 30s)
- Add generation_timeout field to ThumbnailService
- Wrap spawn_blocking in tokio::time::timeout to prevent hanging
- Update DI to pass timeout from config
- Update tests to provide timeout parameter

https://claude.ai/code/session_015FD62aAoMYx1XBZbzPvUu8
This commit is contained in:
Claude
2026-03-28 18:40:34 +00:00
parent 6612c19252
commit dacb8f388e
4 changed files with 112 additions and 67 deletions
+2 -1
View File
@@ -119,12 +119,13 @@ impl AppServiceFactory {
}));
tracing::info!("FileContentCache initialized: max 10MB/file, 512MB total, 10k entries");
// Thumbnail service for thumbnail generation
// Thumbnail service for thumbnail generation with timeout protection
let thumbnail_service = Arc::new(
crate::infrastructure::services::thumbnail_service::ThumbnailService::new(
&self.storage_path,
5000, // max 5000 thumbnails in cache
100 * 1024 * 1024, // max 100MB cache
Some(self.config.timeouts.thumbnail_timeout()),
),
);
// Initialize thumbnail directories