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:
+12
-4
@@ -34,15 +34,18 @@ pub struct TimeoutConfig {
|
||||
pub lock_acquisition_ms: u64,
|
||||
/// Timeout for network operations (ms)
|
||||
pub network_operation_ms: u64,
|
||||
/// Timeout for thumbnail generation (ms)
|
||||
pub thumbnail_generation_ms: u64,
|
||||
}
|
||||
|
||||
impl Default for TimeoutConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
file_operation_ms: 10000, // 10 seconds
|
||||
dir_operation_ms: 30000, // 30 seconds
|
||||
lock_acquisition_ms: 5000, // 5 seconds
|
||||
network_operation_ms: 15000, // 15 seconds
|
||||
file_operation_ms: 10000, // 10 seconds
|
||||
dir_operation_ms: 30000, // 30 seconds
|
||||
lock_acquisition_ms: 5000, // 5 seconds
|
||||
network_operation_ms: 15000, // 15 seconds
|
||||
thumbnail_generation_ms: 30000, // 30 seconds
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +85,11 @@ impl TimeoutConfig {
|
||||
pub fn network_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.network_operation_ms)
|
||||
}
|
||||
|
||||
/// Gets a Duration for thumbnail generation operations
|
||||
pub fn thumbnail_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.thumbnail_generation_ms)
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration for large resource handling
|
||||
|
||||
Reference in New Issue
Block a user