Skip to content

Commit

Permalink
FindFiles: use metadata stow guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hal Clark committed Dec 3, 2024
1 parent 8790561 commit 1d9584d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Operations/FindFiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ bool FindFiles(Drover& DICOM_data,

bool ret = true;

// Store the original state of the key in the global parameter table.
const auto orig_val = get_as<std::string>(InvocationMetadata, Key);
// Stow a copy of the original state of the key in the global parameter table.
auto metadata_stow = stow_metadata(InvocationMetadata, {}, Key);
// Automaticaly restores the stowed metadata when exiting this scope.
metadata_stow_guard msg( InvocationMetadata, metadata_stow );

// Search for files/directories.
std::list< std::filesystem::path > paths;
Expand Down Expand Up @@ -170,12 +172,6 @@ bool FindFiles(Drover& DICOM_data,
}
}

// Restore the key to its original state in the global parameter table.
InvocationMetadata.erase(Key);
if(orig_val){
InvocationMetadata[Key] = orig_val.value();
}

return ret;
}

0 comments on commit 1d9584d

Please sign in to comment.