Don't consider claim errors to be fatal

This commit is contained in:
asonix 2023-07-16 12:33:27 -05:00
parent 61ecb0914b
commit 4ea6710621

View file

@ -110,7 +110,9 @@ impl State {
}
async fn visit_file(&self, path: &Path) -> color_eyre::Result<()> {
let image_response = self.inner.upload(path).await?;
let Some(image_response) = self.inner.upload(path).await? else {
return Ok(());
};
match image_response {
ImageResponse::Ok { files, .. } => {
@ -182,7 +184,7 @@ impl State {
impl StateInner {
#[tracing::instrument(skip(self))]
async fn upload(&self, path: &Path) -> color_eyre::Result<ImageResponse> {
async fn upload(&self, path: &Path) -> color_eyre::Result<Option<ImageResponse>> {
let guard = self.semaphore.acquire().await?;
let filename = path
@ -210,7 +212,8 @@ impl StateInner {
let mut uploads = match response {
UploadReponse::Error { msg } => {
return Err(eyre::eyre!("Error uploading image: {msg}"))
tracing::warn!("Upload for {path:?} failed with message\n{msg}");
return Ok(None);
}
UploadReponse::Ok { uploads, .. } => uploads,
};
@ -223,7 +226,7 @@ impl StateInner {
drop(guard);
Ok(response)
Ok(Some(response))
}
async fn long_poll(&self, upload: &Upload) -> color_eyre::Result<ImageResponse> {
@ -294,7 +297,12 @@ impl MultiError {
impl std::fmt::Display for MultiError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut first = true;
for e in &self.errors {
if !first {
writeln!(f)?;
}
first = false;
e.fmt(f)?;
}
Ok(())