perf: rewrite batch download_zip to stream via temp file instead of RAM

- Replace in-memory Cursor<Vec<u8>> with async_zip + NamedTempFile (O(256KB) RAM)
- Stream ZIP to client via ReaderStream instead of materializing entire archive
- Replace N+1 BFS folder traversal with 2 bulk ltree queries
- Remove dead zip_service field and with_zip_service() from BatchOperationService
- Remove synchronous zip crate dependency (only async_zip remains)
- Eliminates ~2.5GB RAM spike per 2GB batch download
This commit is contained in:
Dionisio
2026-02-25 23:12:19 +01:00
parent 23474b9681
commit 5f883aa0f8
5 changed files with 176 additions and 347 deletions
-2
View File
@@ -94,8 +94,6 @@ pub fn create_api_routes(app_state: &Arc<AppState>) -> Router<Arc<AppState>> {
if let Some(ref ts) = trash_service {
batch_service_builder = batch_service_builder.with_trash_service(ts.clone());
}
let zip_service_ref = app_state.core.zip_service.clone();
batch_service_builder = batch_service_builder.with_zip_service(zip_service_ref);
let batch_service = Arc::new(batch_service_builder);
// Create state for the batch operations handler