mirror of https://github.com/dswd/zvault
Some minor fixes
This commit is contained in:
parent
249af7bbd4
commit
600ed7c245
|
@ -34,6 +34,9 @@ quick_error!{
|
||||||
description("Failed to read/write bundle cache")
|
description("Failed to read/write bundle cache")
|
||||||
display("Bundle db error: failed to read/write bundle cache\n\tcaused by: {}", err)
|
display("Bundle db error: failed to read/write bundle cache\n\tcaused by: {}", err)
|
||||||
}
|
}
|
||||||
|
UploadFailed {
|
||||||
|
description("Uploading a bundle failed")
|
||||||
|
}
|
||||||
Io(err: io::Error, path: PathBuf) {
|
Io(err: io::Error, path: PathBuf) {
|
||||||
cause(err)
|
cause(err)
|
||||||
context(path: &'a Path, err: io::Error) -> (err, path.to_path_buf())
|
context(path: &'a Path, err: io::Error) -> (err, path.to_path_buf())
|
||||||
|
|
|
@ -36,7 +36,11 @@ impl BundleUploader {
|
||||||
if self.error_present.load(Ordering::SeqCst) {
|
if self.error_present.load(Ordering::SeqCst) {
|
||||||
let mut error = None;
|
let mut error = None;
|
||||||
mem::swap(&mut error, &mut self.error.lock().unwrap());
|
mem::swap(&mut error, &mut self.error.lock().unwrap());
|
||||||
Err(error.unwrap())
|
if let Some(err) = error {
|
||||||
|
Err(err)
|
||||||
|
} else {
|
||||||
|
Err(BundleDbError::UploadFailed)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -82,10 +86,11 @@ impl BundleUploader {
|
||||||
|
|
||||||
fn worker_thread(&self) {
|
fn worker_thread(&self) {
|
||||||
if let Err(err) = self.worker_thread_inner() {
|
if let Err(err) = self.worker_thread_inner() {
|
||||||
|
debug!("Upload thread failed with error: {}", err);
|
||||||
*self.error.lock().unwrap() = Some(err);
|
*self.error.lock().unwrap() = Some(err);
|
||||||
self.error_present.store(true, Ordering::SeqCst);
|
self.error_present.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
self.waiting.swap(0, Ordering::SeqCst);
|
self.waiting.store(0, Ordering::SeqCst);
|
||||||
self.wait.0.notify_all();
|
self.wait.0.notify_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,6 +341,8 @@ impl Repository {
|
||||||
|
|
||||||
impl Drop for Repository {
|
impl Drop for Repository {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.flush().expect("Failed to write last bundles")
|
if let Err(err) = self.flush() {
|
||||||
|
error!("Failed to flush repository: {}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue