From 9801f602d71591eb5e47b869f649b44e5651b146 Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Tue, 2 Apr 2024 12:15:16 -0400 Subject: [PATCH] Centralize mapping file key construction --- src/scan/layout.rs | 12 ++++++------ src/scan/saves.rs | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/scan/layout.rs b/src/scan/layout.rs index 6de6ba6..6b5faed 100644 --- a/src/scan/layout.rs +++ b/src/scan/layout.rs @@ -961,7 +961,7 @@ impl GameLayout { match file.change() { ScanChange::New | ScanChange::Different | ScanChange::Same => { files.insert( - file.effective().render(), + file.mapping_key(), IndividualMappingFile { hash: file.hash.clone(), size: file.size, @@ -1007,7 +1007,7 @@ impl GameLayout { match file.change() { ScanChange::New | ScanChange::Different | ScanChange::Same => { files.insert( - file.effective().render(), + file.mapping_key(), Some(IndividualMappingFile { hash: file.hash.clone(), size: file.size, @@ -1015,7 +1015,7 @@ impl GameLayout { ); } ScanChange::Removed => { - files.insert(file.effective().render(), None); + files.insert(file.mapping_key(), None); } ScanChange::Unknown => (), }; @@ -1068,7 +1068,7 @@ impl GameLayout { let mut relevant_files = vec![]; for file in &scan.found_files { - if !backup.includes_file(file.effective().render()) { + if !backup.includes_file(file.mapping_key()) { log::debug!("[{}] skipped: {}", self.mapping.name, file.path.raw()); continue; } @@ -1153,7 +1153,7 @@ impl GameLayout { .large_file(true); 'item: for file in &scan.found_files { - if !backup.includes_file(file.effective().render()) { + if !backup.includes_file(file.mapping_key()) { log::debug!("[{}] skipped: {}", self.mapping.name, file.path.raw()); continue; } @@ -1373,7 +1373,7 @@ impl GameLayout { for file in self.restorable_files_in_simple(&backup.name) { files.insert( - file.original_path.unwrap().render(), + file.mapping_key(), IndividualMappingFile { hash: file.path.sha1(), size: file.path.size(), diff --git a/src/scan/saves.rs b/src/scan/saves.rs index f90357f..d1bdbb8 100644 --- a/src/scan/saves.rs +++ b/src/scan/saves.rs @@ -88,7 +88,12 @@ impl ScannedFile { self.original_path.is_some() } - /// This is stored in the mapping file and used for operations. + /// This is stored in the mapping file. + pub fn mapping_key(&self) -> String { + self.effective().render() + } + + /// This is used for operations. pub fn effective(&self) -> &StrictPath { self.redirected.as_ref().unwrap_or_else(|| self.original_path()) }