From 600ed7c245061adefe166873a59fce2a4b99dac1 Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Wed, 12 Apr 2017 11:34:31 +0200 Subject: [PATCH] Some minor fixes --- src/bundledb/db.rs | 3 +++ src/bundledb/uploader.rs | 9 +++++++-- src/repository/mod.rs | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bundledb/db.rs b/src/bundledb/db.rs index 0608331..ca3183f 100644 --- a/src/bundledb/db.rs +++ b/src/bundledb/db.rs @@ -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()) diff --git a/src/bundledb/uploader.rs b/src/bundledb/uploader.rs index 9be818f..0e02713 100644 --- a/src/bundledb/uploader.rs +++ b/src/bundledb/uploader.rs @@ -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(); } } diff --git a/src/repository/mod.rs b/src/repository/mod.rs index 9fee7af..3a135eb 100644 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -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); + } } }