summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-08-08 14:35:58 +0300
committerLars Wirzenius <liw@liw.fi>2021-08-09 09:58:38 +0300
commit30c20dcf3d81e9147e2bd4617bd055a5a8a17896 (patch)
tree0d2ee0d8b93fce54a16ec252e8ba167a0695af54 /src
parent0faa5f4953c81bbb81e875a87b8322ecfdd97cf2 (diff)
downloadobnam2-30c20dcf3d81e9147e2bd4617bd055a5a8a17896.tar.gz
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
Diffstat (limited to 'src')
-rw-r--r--src/generation.rs43
1 files changed, 12 insertions, 31 deletions
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<Item = Result<FsEntryBackupOutcome, BackupError>>,
- ) -> Result<Vec<BackupError>, 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);