minor cleanups
This commit is contained in:
parent
876869b073
commit
5b018cf84b
2 changed files with 13 additions and 14 deletions
|
|
@ -46,18 +46,15 @@ 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 {
|
||||||
None => {
|
|
||||||
warn!("attempted to rewind twice");
|
warn!("attempted to rewind twice");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn read<'t>(&mut self, buf: &'t mut [u8]) -> io::Result<Chunk<'t>> {
|
pub fn read<'t>(&mut self, buf: &'t mut [u8]) -> io::Result<Chunk<'t>> {
|
||||||
let mut f = fs::File::open(&self.path)?;
|
let mut f = fs::File::open(&self.path)?;
|
||||||
|
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -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| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue