Some minor fixes

pull/10/head
Dennis Schwerdel 6 years ago
parent 249af7bbd4
commit 600ed7c245

@ -34,6 +34,9 @@ quick_error!{
description("Failed to read/write bundle cache")
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) {
cause(err)
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) {
let mut error = None;
mem::swap(&mut error, &mut self.error.lock().unwrap());
Err(error.unwrap())
if let Some(err) = error {
Err(err)
} else {
Err(BundleDbError::UploadFailed)
}
} else {
Ok(())
}
@ -82,10 +86,11 @@ impl BundleUploader {
fn worker_thread(&self) {
if let Err(err) = self.worker_thread_inner() {
debug!("Upload thread failed with error: {}", err);
*self.error.lock().unwrap() = Some(err);
self.error_present.store(true, Ordering::SeqCst);
}
self.waiting.swap(0, Ordering::SeqCst);
self.waiting.store(0, Ordering::SeqCst);
self.wait.0.notify_all();
}
}

@ -341,6 +341,8 @@ impl Repository {
impl Drop for Repository {
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…
Cancel
Save