diff options
Diffstat (limited to 'src/generation.rs')
-rw-r--r-- | src/generation.rs | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/src/generation.rs b/src/generation.rs index 5412ae7..bd36a19 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -1,8 +1,6 @@ use crate::backup_reason::Reason; -use crate::backup_run::{BackupError, FsEntryBackupOutcome}; use crate::chunkid::ChunkId; use crate::fsentry::FilesystemEntry; -use log::debug; use rusqlite::Connection; use std::fmt; use std::path::{Path, PathBuf}; @@ -50,9 +48,6 @@ pub enum NascentError { #[error(transparent)] LocalGenerationError(#[from] LocalGenerationError), - #[error(transparent)] - BackupError(#[from] BackupError), - #[error("SQL transaction error: {0}")] Transaction(rusqlite::Error), @@ -89,33 +84,6 @@ impl NascentGeneration { t.commit().map_err(NascentError::Commit)?; Ok(()) } - - pub fn insert_iter( - &mut self, - entries: impl Iterator<Item = Result<FsEntryBackupOutcome, BackupError>>, - ) -> Result<Vec<BackupError>, NascentError> { - let t = self.conn.transaction().map_err(NascentError::Transaction)?; - let mut warnings = vec![]; - for r in entries { - match r { - Err(err) => { - debug!("ignoring backup error {}", err); - warnings.push(err); - } - Ok(FsEntryBackupOutcome { - entry, - ids, - reason, - is_cachedir_tag, - }) => { - self.fileno += 1; - sql::insert_one(&t, entry, self.fileno, &ids[..], reason, is_cachedir_tag)?; - } - } - } - t.commit().map_err(NascentError::Commit)?; - Ok(warnings) - } } /// A finished generation. @@ -479,6 +447,9 @@ mod test { assert!(filename.exists()); } + // FIXME: This is way too complicated a test function. It should + // be simplified, possibly by re-thinking the abstractions of the + // code it calls. #[test] fn remembers_cachedir_tags() { use crate::{ @@ -516,20 +487,24 @@ mod test { .unwrap(); let entries = vec![ - Ok(FsEntryBackupOutcome { + FsEntryBackupOutcome { entry: FilesystemEntry::from_metadata(nontag_path2, &metadata).unwrap(), ids: vec![], reason: Reason::IsNew, is_cachedir_tag: false, - }), - Ok(FsEntryBackupOutcome { + }, + FsEntryBackupOutcome { entry: FilesystemEntry::from_metadata(tag_path2, &metadata).unwrap(), ids: vec![], reason: Reason::IsNew, is_cachedir_tag: true, - }), + }, ]; - gen.insert_iter(entries.into_iter()).unwrap(); + + for o in entries { + gen.insert(o.entry, &o.ids, o.reason, o.is_cachedir_tag) + .unwrap(); + } drop(gen); |