Skip to content

Commit

Permalink
Fix different ignored saves in consecutive differential backup
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jun 30, 2024
1 parent 30f6308 commit c37478e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Unreleased

* Fixed:
* If two consecutive differential backups both ignored *different* save files
*and* none of those files were ignored in the associated full backup,
then the second differential backup would fail to redeclare
the first differential backup's ignored saves.
* GUI: On Mac, the file/folder selector would cause the app to crash.

## v0.24.2 (2024-06-28)
Expand Down
60 changes: 59 additions & 1 deletion src/scan/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ impl GameLayout {
ScanChange::New | ScanChange::Different | ScanChange::Same => {
files.insert(
file.mapping_key(),
Some(IndividualMappingFile {
(!file.ignored).then(|| IndividualMappingFile {
hash: file.hash.clone(),
size: file.size,
}),
Expand Down Expand Up @@ -2589,6 +2589,64 @@ mod tests {
);
}

#[test]
fn can_plan_second_differential_backup_with_different_ignored_files() {
let scan = ScanInfo {
found_files: hash_set! {
// Ignored in first differential backup:
ScannedFile::with_change(repo_file("file1"), 1, "1", ScanChange::New).ignored(),
// Newly ignored:
ScannedFile::with_change(repo_file("file2"), 2, "2", ScanChange::Same).ignored(),
// Just here to keep the backup from being inert (all ignores):
ScannedFile::with_change(repo_file("file3"), 3, "3", ScanChange::Same),
},
..Default::default()
};
let layout = GameLayout {
mapping: IndividualMapping {
drives: drives(),
backups: VecDeque::from_iter(vec![FullBackup {
name: ".".to_string(),
when: past(),
files: btree_map! {
StrictPath::new(repo_file("file1")).render(): IndividualMappingFile { hash: "1".into(), size: 1 },
StrictPath::new(repo_file("file2")).render(): IndividualMappingFile { hash: "2".into(), size: 2 },
StrictPath::new(repo_file("file3")).render(): IndividualMappingFile { hash: "3".into(), size: 3 },
},
children: VecDeque::from([DifferentialBackup {
name: format!("backup-{}-diff", now_str()),
when: now(),
os: Some(Os::HOST),
files: btree_map! {
StrictPath::new(repo_file("file1")).render(): None,
},
..Default::default()
}]),
..Default::default()
}]),
..Default::default()
},
..Default::default()
};
assert_eq!(
DifferentialBackup {
name: format!("backup-{}-diff", now_str()),
when: now(),
os: Some(Os::HOST),
files: btree_map! {
// This matches the latest composite,
// but we have to reiterate this in the new differential:
StrictPath::new(repo_file("file1")).render(): None,
// New ignore:
StrictPath::new(repo_file("file2")).render(): None,
},
registry: None,
..Default::default()
},
layout.plan_differential_backup(&scan, &now(), &BackupFormats::default()),
);
}

#[test]
#[cfg(target_os = "windows")]
fn can_plan_differential_backup_with_registry_new() {
Expand Down

0 comments on commit c37478e

Please sign in to comment.