mirror of
https://github.com/flibusta-apps/batch_downloader.git
synced 2025-12-06 06:15:37 +01:00
Fix download bug
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::{fs::File, io::Seek};
|
||||
use std::{fs::File, io::Write};
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use smartstring::alias::String as SmartString;
|
||||
@@ -134,7 +134,7 @@ pub async fn create_archive(
|
||||
Err(err) => return Err(Box::new(err)),
|
||||
};
|
||||
|
||||
archive_result.rewind().unwrap();
|
||||
archive_result.flush()?;
|
||||
|
||||
Ok((archive_result, bytes_count))
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use axum::{
|
||||
Json, Router,
|
||||
};
|
||||
use axum_prometheus::PrometheusMetricLayer;
|
||||
use moka::future::Cache;
|
||||
use moka::{future::Cache, notification::RemovalCause};
|
||||
use once_cell::sync::Lazy;
|
||||
use tokio::fs::File;
|
||||
use tokio_util::io::ReaderStream;
|
||||
@@ -28,8 +28,12 @@ pub static TASK_RESULTS: Lazy<Cache<String, Task>> = Lazy::new(|| {
|
||||
Cache::builder()
|
||||
.time_to_idle(Duration::from_secs(3 * 60 * 60))
|
||||
.max_capacity(2048)
|
||||
.async_eviction_listener(|_key, value: Task, _reason| {
|
||||
.async_eviction_listener(|_key, value: Task, reason| {
|
||||
Box::pin(async move {
|
||||
if reason == RemovalCause::Replaced {
|
||||
return;
|
||||
}
|
||||
|
||||
let _ = tokio::fs::remove_file(format!("/tmp/{}", value.id)).await;
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user