Skip to content

Commit

Permalink
Centralize mapping file key construction
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Apr 2, 2024
1 parent cfd3085 commit 9801f60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/scan/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1007,15 +1007,15 @@ 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,
}),
);
}
ScanChange::Removed => {
files.insert(file.effective().render(), None);
files.insert(file.mapping_key(), None);
}
ScanChange::Unknown => (),
};
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(),
Expand Down
7 changes: 6 additions & 1 deletion src/scan/saves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit 9801f60

Please sign in to comment.