Compare commits
2 commits
3b46d228f4
...
540953e4a9
| Author | SHA1 | Date | |
|---|---|---|---|
| 540953e4a9 | |||
| c734355ebb |
5 changed files with 30 additions and 43 deletions
1
notes.md
1
notes.md
|
|
@ -53,3 +53,4 @@
|
||||||
- hashing
|
- hashing
|
||||||
- store file hashes with all `file::*` variants
|
- store file hashes with all `file::*` variants
|
||||||
- check hashes on "continue"
|
- check hashes on "continue"
|
||||||
|
- CLI switch to skip hashing
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ impl AppState {
|
||||||
}
|
}
|
||||||
Err(path) => {
|
Err(path) => {
|
||||||
debug!("Finished {:?}!", path.display());
|
debug!("Finished {:?}!", path.display());
|
||||||
self.end_progressbar(|pb| pb.finish());
|
self.end_progressbar(ProgressBar::finish);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,15 +174,11 @@ impl AppState {
|
||||||
let checked = uploading.abort();
|
let checked = uploading.abort();
|
||||||
self.inner.requeue_file(checked);
|
self.inner.requeue_file(checked);
|
||||||
|
|
||||||
self.end_progressbar(|pb| pb.abandon());
|
self.end_progressbar(ProgressBar::abandon);
|
||||||
|
|
||||||
Some(self)
|
Some(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_names(&self) -> Vec<&str> {
|
|
||||||
self.inner.file_names()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn save(&self) -> io::Result<()> {
|
pub fn save(&self) -> io::Result<()> {
|
||||||
self.inner.save()
|
self.inner.save()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::Cli,
|
cli::Cli,
|
||||||
file::{self, Chunk, FileTrait},
|
file::{self, Chunk},
|
||||||
sharry::{self, Client, Uri},
|
sharry::{self, Client, Uri},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -21,13 +21,6 @@ enum FileState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileState {
|
impl FileState {
|
||||||
fn file_name(&self) -> &str {
|
|
||||||
match self {
|
|
||||||
FileState::C(c) => c.get_name(),
|
|
||||||
FileState::U(u) => u.get_name(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn start_upload(
|
fn start_upload(
|
||||||
self,
|
self,
|
||||||
client: &impl sharry::Client,
|
client: &impl sharry::Client,
|
||||||
|
|
@ -92,10 +85,6 @@ impl CacheFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_names(&self) -> Vec<&str> {
|
|
||||||
self.files.iter().map(FileState::file_name).collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.files.is_empty()
|
self.files.is_empty()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use clap::{
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
file::Checked,
|
file::{Checked, FileTrait},
|
||||||
sharry::{NewShareRequest, Uri},
|
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 {
|
pub fn get_hash(&self) -> String {
|
||||||
let file_refs = {
|
let file_refs = {
|
||||||
let mut refs: Vec<_> = self.files.iter().collect();
|
let mut refs: Vec<_> = self.files.iter().collect();
|
||||||
|
|
|
||||||
45
src/main.rs
45
src/main.rs
|
|
@ -73,7 +73,7 @@ fn main() {
|
||||||
|
|
||||||
info!("continuing with state: {state:#?}");
|
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);
|
println!("{} is uploading: {fns_magenta}", *SHRUPL);
|
||||||
|
|
||||||
|
|
@ -90,33 +90,30 @@ fn main() {
|
||||||
Log::handle(&e);
|
Log::handle(&e);
|
||||||
tries += 1;
|
tries += 1;
|
||||||
|
|
||||||
match e {
|
if let ClientError::InvalidParameter(p) = e { match p {
|
||||||
ClientError::InvalidParameter(p) => match p {
|
// TODO Error 404: File not found
|
||||||
// TODO Error 404: File not found
|
Parameter::FileID(fid) => {
|
||||||
Parameter::FileID(fid) => {
|
// requeue file
|
||||||
// requeue file
|
let Some(s) = state.requeue_file() else {
|
||||||
let Some(s) = state.requeue_file() else {
|
Log::error("Failed to requeue file!");
|
||||||
Log::error("Failed to requeue file!");
|
|
||||||
};
|
|
||||||
|
|
||||||
trace!("File {fid:?} requeued (tried: {tries})");
|
|
||||||
state = s;
|
|
||||||
}
|
|
||||||
// TODO Error 404: Share might have been deleted
|
|
||||||
Parameter::ShareID(sid) => {
|
|
||||||
Log::error(format_args!("404 sid: {sid}"));
|
|
||||||
}
|
|
||||||
p => Log::error(format_args!("Unexpected {p}!")),
|
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
// retry chunk
|
|
||||||
let Some(s) = state.rewind() else {
|
|
||||||
Log::error("Failed to retry chunk!");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!("State rewound, retrying last chunk (tried: {tries})");
|
trace!("File {fid:?} requeued (tried: {tries})");
|
||||||
state = s;
|
state = s;
|
||||||
}
|
}
|
||||||
|
// TODO Error 404: Share might have been deleted
|
||||||
|
Parameter::ShareID(sid) => {
|
||||||
|
Log::error(format_args!("404 sid: {sid}"));
|
||||||
|
}
|
||||||
|
p => Log::error(format_args!("Unexpected {p}!")),
|
||||||
|
} } else {
|
||||||
|
// retry chunk
|
||||||
|
let Some(s) = state.rewind() else {
|
||||||
|
Log::error("Failed to retry chunk!");
|
||||||
|
};
|
||||||
|
|
||||||
|
trace!("State rewound, retrying last chunk (tried: {tries})");
|
||||||
|
state = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue