From 30c20dcf3d81e9147e2bd4617bd055a5a8a17896 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 8 Aug 2021 14:35:58 +0300 Subject: refactor: drop NascentGeneration::insert_iter It was only used by a test function, which is now changed to not use it. Add comment to the test function that it's too complicated and things need refactoring. However, that probably needs to wait for new abstractions. Sponsored-by: author --- src/generation.rs | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/generation.rs b/src/generation.rs index 49e42f5..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}; @@ -86,30 +84,6 @@ impl NascentGeneration { t.commit().map_err(NascentError::Commit)?; Ok(()) } - - pub fn insert_iter( - &mut self, - entries: impl Iterator>, - ) -> Result, NascentError> { - 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.insert(entry, &ids, reason, is_cachedir_tag)?; - } - } - } - Ok(warnings) - } } /// A finished generation. @@ -473,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::{ @@ -510,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); -- cgit v1.2.1