summaryrefslogtreecommitdiff
path: root/src/generation.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-03-12 11:12:46 +0200
committerLars Wirzenius <liw@liw.fi>2021-03-12 12:00:00 +0200
commit0fcb8f314a054e4c92e49461f1ae2d9392756638 (patch)
tree9d1690d3e4b23217a65412342de160c2dac49d48 /src/generation.rs
parent77e293e36d741a7f6e318672061d522d9dc35f6b (diff)
downloadobnam2-0fcb8f314a054e4c92e49461f1ae2d9392756638.tar.gz
feat: show warnings for any problems backing up files
Previously, we either ignored it or aborted the backup. Neither is good. Now we ignore the problem, except to show a warning at the end of the backup run.
Diffstat (limited to 'src/generation.rs')
-rw-r--r--src/generation.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/generation.rs b/src/generation.rs
index 4655c17..240f46a 100644
--- a/src/generation.rs
+++ b/src/generation.rs
@@ -2,6 +2,7 @@ use crate::backup_reason::Reason;
use crate::backup_run::{BackupError, BackupResult};
use crate::chunkid::ChunkId;
use crate::fsentry::FilesystemEntry;
+use log::debug;
use rusqlite::Connection;
use std::path::{Path, PathBuf};
@@ -64,15 +65,23 @@ impl NascentGeneration {
pub fn insert_iter<'a>(
&mut self,
entries: impl Iterator<Item = BackupResult<(FilesystemEntry, Vec<ChunkId>, Reason)>>,
- ) -> NascentResult<()> {
+ ) -> NascentResult<Vec<BackupError>> {
let t = self.conn.transaction()?;
+ let mut warnings = vec![];
for r in entries {
- let (e, ids, reason) = r?;
- self.fileno += 1;
- sql::insert_one(&t, e, self.fileno, &ids[..], reason)?;
+ match r {
+ Err(err) => {
+ debug!("ignoring backup error {}", err);
+ warnings.push(err);
+ }
+ Ok((e, ids, reason)) => {
+ self.fileno += 1;
+ sql::insert_one(&t, e, self.fileno, &ids[..], reason)?;
+ }
+ }
}
t.commit()?;
- Ok(())
+ Ok(warnings)
}
}