diff --git a/notes.md b/notes.md index e908092..7603faa 100644 --- a/notes.md +++ b/notes.md @@ -53,3 +53,4 @@ - hashing - store file hashes with all `file::*` variants - check hashes on "continue" + - CLI switch to skip hashing diff --git a/src/appstate.rs b/src/appstate.rs index 2617861..8223df8 100644 --- a/src/appstate.rs +++ b/src/appstate.rs @@ -86,9 +86,8 @@ impl AppState { bar.set_position(upl.get_offset()); // BUG in `indicatif` crate? - // `set_position` does not force an immediate redraw, so we also call `inc_length` here + // `set_position` does not force an immediate redraw, so we need to call `set_length` after bar.set_length(upl.get_size()); - // bar.inc_length(0); f(bar); @@ -163,13 +162,10 @@ impl AppState { self.http .share_create(&args.get_uri(), &args.alias, args.get_share_request())?; + self.with_progressbar(true, ProgressBar::abandon); Ok(Self::new(self.http, CacheFile::from_args(args, share_id))) } - pub fn file_names(&self) -> Vec<&str> { - self.inner.file_names() - } - pub fn save(&self) -> io::Result<()> { self.inner.save() } diff --git a/src/cachefile.rs b/src/cachefile.rs index 0478355..897dfd7 100644 --- a/src/cachefile.rs +++ b/src/cachefile.rs @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize}; use crate::{ cli::Cli, - file::{self, Chunk, FileTrait}, + file::{self, Chunk}, sharry::{self, Client, Uri}, }; @@ -67,17 +67,6 @@ impl CacheFile { } } - pub fn file_names(&self) -> Vec<&str> { - let mut result = vec![]; - - if let Some(upl) = self.uploading.as_ref() { - result.push(upl.get_name()); - } - self.files.iter().map(|chk| result.push(chk.get_name())); - - result - } - pub fn queue_empty(&self) -> bool { self.files.is_empty() } diff --git a/src/cli.rs b/src/cli.rs index 5d56f5e..546427b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -14,7 +14,7 @@ use clap::{ use log::LevelFilter; use crate::{ - file::Checked, + file::{Checked, FileTrait}, sharry::{NewShareRequest, Uri}, }; @@ -130,6 +130,10 @@ impl Cli { } } + pub fn file_names(&self) -> Vec<&str> { + self.files.iter().map(FileTrait::get_name).collect() + } + pub fn get_hash(&self) -> String { let file_refs = { let mut refs: Vec<_> = self.files.iter().collect(); diff --git a/src/main.rs b/src/main.rs index cd711d6..8d5c73c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,7 +73,7 @@ fn main() { info!("continuing with state: {state:#?}"); - let fns_magenta = output::style_all(&state.file_names(), |s| style(s).magenta()).join(", "); + let fns_magenta = output::style_all(&args.file_names(), |s| style(s).magenta()).join(", "); println!("{} is uploading: {fns_magenta}", *SHRUPL);