minor cleanups

This commit is contained in:
Jörn-Michael Miehe 2025-06-13 23:11:40 +00:00
parent 876869b073
commit 5b018cf84b
2 changed files with 13 additions and 14 deletions

View file

@ -46,16 +46,13 @@ impl Uploading {
} }
pub fn rewind(self) -> Option<Self> { pub fn rewind(self) -> Option<Self> {
match self.last_offset { if let Some(last_offset) = self.last_offset { Some(Self {
Some(last_offset) => Some(Self { last_offset: None,
last_offset: None, offset: last_offset,
offset: last_offset, ..self
..self }) } else {
}), warn!("attempted to rewind twice");
None => { None
warn!("attempted to rewind twice");
None
}
} }
} }

View file

@ -15,7 +15,7 @@ use std::{
use clap::Parser; use clap::Parser;
use console::style; use console::style;
use dialoguer::{Confirm, theme::ColorfulTheme}; use dialoguer::{Confirm, theme::ColorfulTheme};
use log::{error, info}; use log::{error, info, trace};
use appstate::AppState; use appstate::AppState;
use cli::Cli; use cli::Cli;
@ -118,7 +118,7 @@ fn main() {
loop { loop {
match state.upload_chunk(&mut buffer) { match state.upload_chunk(&mut buffer) {
Err(e) => { Err(e) => {
// HACK handle errors better // HACK handle errors better (this will just retry endlessly)
error!("error: {e:?}"); error!("error: {e:?}");
if let Some(s) = state.rewind() { if let Some(s) = state.rewind() {
@ -126,13 +126,15 @@ fn main() {
} else { } else {
eprintln!("{} Failed to retry chunk!", style("Error:").red().bold()); eprintln!("{} Failed to retry chunk!", style("Error:").red().bold());
process::exit(1); process::exit(1);
}; }
}
Ok(false) => {
trace!("chunk uploaded");
} }
Ok(true) => { Ok(true) => {
info!("all uploads done"); info!("all uploads done");
break; break;
} }
_ => (),
} }
state.save().unwrap_or_else(|e| { state.save().unwrap_or_else(|e| {