diff --git a/src/file/uploading.rs b/src/file/uploading.rs index 0b2118f..0554527 100644 --- a/src/file/uploading.rs +++ b/src/file/uploading.rs @@ -46,16 +46,13 @@ impl Uploading { } pub fn rewind(self) -> Option { - match self.last_offset { - Some(last_offset) => Some(Self { - last_offset: None, - offset: last_offset, - ..self - }), - None => { - warn!("attempted to rewind twice"); - None - } + if let Some(last_offset) = self.last_offset { Some(Self { + last_offset: None, + offset: last_offset, + ..self + }) } else { + warn!("attempted to rewind twice"); + None } } diff --git a/src/main.rs b/src/main.rs index 974e1dd..4f62808 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use std::{ use clap::Parser; use console::style; use dialoguer::{Confirm, theme::ColorfulTheme}; -use log::{error, info}; +use log::{error, info, trace}; use appstate::AppState; use cli::Cli; @@ -118,7 +118,7 @@ fn main() { loop { match state.upload_chunk(&mut buffer) { Err(e) => { - // HACK handle errors better + // HACK handle errors better (this will just retry endlessly) error!("error: {e:?}"); if let Some(s) = state.rewind() { @@ -126,13 +126,15 @@ fn main() { } else { eprintln!("{} Failed to retry chunk!", style("Error:").red().bold()); process::exit(1); - }; + } + } + Ok(false) => { + trace!("chunk uploaded"); } Ok(true) => { info!("all uploads done"); break; } - _ => (), } state.save().unwrap_or_else(|e| {