Some minor fixes

This commit is contained in:
Dennis Schwerdel 2017-04-12 11:34:31 +02:00
parent 249af7bbd4
commit 600ed7c245
3 changed files with 13 additions and 3 deletions

View File

@ -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())

View File

@ -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();
}
}

View File

@ -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);
}
}
}