mirror of
https://github.com/zhaofengli/attic.git
synced 2024-12-14 11:57:30 +00:00
Log stream errors
This commit is contained in:
parent
4dbdbee457
commit
a4f2cae9dd
1 changed files with 11 additions and 2 deletions
|
@ -9,6 +9,7 @@ use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use axum::body::HttpBody as _;
|
||||||
use axum::{
|
use axum::{
|
||||||
body::StreamBody,
|
body::StreamBody,
|
||||||
extract::{Extension, Path},
|
extract::{Extension, Path},
|
||||||
|
@ -217,7 +218,11 @@ async fn get_nar(
|
||||||
Download::Url(url) => Ok(Redirect::temporary(&url).into_response()),
|
Download::Url(url) => Ok(Redirect::temporary(&url).into_response()),
|
||||||
Download::AsyncRead(stream) => {
|
Download::AsyncRead(stream) => {
|
||||||
let stream = ReaderStream::new(stream);
|
let stream = ReaderStream::new(stream);
|
||||||
let body = StreamBody::new(stream);
|
let body = StreamBody::new(stream).map_err(|e| {
|
||||||
|
tracing::error!("Stream error: {e}");
|
||||||
|
e
|
||||||
|
});
|
||||||
|
|
||||||
Ok(body.into_response())
|
Ok(body.into_response())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +255,11 @@ async fn get_nar(
|
||||||
// TODO: Make num_prefetch configurable
|
// TODO: Make num_prefetch configurable
|
||||||
// The ideal size depends on the average chunk size
|
// The ideal size depends on the average chunk size
|
||||||
let merged = merge_chunks(chunks, streamer, storage, 2);
|
let merged = merge_chunks(chunks, streamer, storage, 2);
|
||||||
let body = StreamBody::new(merged);
|
let body = StreamBody::new(merged).map_err(|e| {
|
||||||
|
tracing::error!("Stream error: {e}");
|
||||||
|
e
|
||||||
|
});
|
||||||
|
|
||||||
Ok(body.into_response())
|
Ok(body.into_response())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue