Complete upload progress bar implementation, simplify with arc/mutex

This commit is contained in:
timvisee 2018-03-19 21:52:20 +01:00
parent 030454cc10
commit b57e85a8ec
No known key found for this signature in database
GPG key ID: 109CBA0BF74036C2
4 changed files with 29 additions and 20 deletions

View file

@ -1,5 +1,5 @@
use std::path::Path;
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use ffsend_api::action::upload::Upload as ApiUpload;
use ffsend_api::reqwest::Client;
@ -34,7 +34,7 @@ impl<'a> Upload<'a> {
let client = Client::new();
// Create a progress bar reporter
let bar = Box::new(ProgressBar::new());
let bar = Arc::new(Mutex::new(ProgressBar::new()));
// Execute an upload action
// TODO: do not unwrap, but return an error

View file

@ -42,7 +42,6 @@ impl ProgressReporter for ProgressBar {
fn finish(&mut self) {
self.bar.as_mut()
.expect("progress bar not yet instantiated")
// TODO: print a proper message here
.finish_print("DONE");
.finish_print("File uploaded");
}
}