Ignore 204 from files server

This commit is contained in:
2024-05-07 17:59:27 +02:00
parent b2951c71c9
commit b8a7d7ccb1
3 changed files with 9 additions and 6 deletions

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@
.vscode .vscode
.env .env
.DS_Store

View File

@@ -28,7 +28,7 @@ pub async fn download_from_downloader(
source_id: u32, source_id: u32,
remote_id: u32, remote_id: u32,
object_type: String, object_type: String,
) -> Result<Response, Box<dyn std::error::Error + Send + Sync>> { ) -> Result<Option<Response>, Box<dyn std::error::Error + Send + Sync>> {
let url = format!( let url = format!(
"{}/download/{source_id}/{remote_id}/{object_type}", "{}/download/{source_id}/{remote_id}/{object_type}",
CONFIG.downloader_url CONFIG.downloader_url
@@ -42,12 +42,10 @@ pub async fn download_from_downloader(
.error_for_status()?; .error_for_status()?;
if response.status() == StatusCode::NO_CONTENT { if response.status() == StatusCode::NO_CONTENT {
return Err(Box::new(DownloadError { return Ok(None);
status_code: StatusCode::NO_CONTENT,
}));
}; };
Ok(response) Ok(Some(response))
} }
pub async fn get_filename( pub async fn get_filename(

View File

@@ -138,7 +138,10 @@ pub async fn cache_file(
let downloader_result = let downloader_result =
match download_from_downloader(book.source.id, book.remote_id, object_type.clone()).await { match download_from_downloader(book.source.id, book.remote_id, object_type.clone()).await {
Ok(v) => v, Ok(v) => match v {
Some(v) => v,
None => return None,
},
Err(err) => { Err(err) => {
log::error!("{:?}", err); log::error!("{:?}", err);
return None; return None;