Skip to content

Commit

Permalink
Stop removing from map without fixing the iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnovak committed Feb 27, 2025
1 parent 77bd6f6 commit 67637a6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/subcommand/giraffe_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ int main_giraffe(int argc, char** argv) {
// The IndexRegistry doesn't try to infer index files based on the
// basename, so do that here. We can have multiple extension options that
// we try in order of priority.
// When found, the index is removed from this map.
unordered_map<string, vector<string>> indexes_and_extensions = {
{"Giraffe GBZ", {"giraffe.gbz", "gbz"}},
{"XG", {"xg"}},
Expand All @@ -1624,9 +1625,10 @@ int main_giraffe(int argc, char** argv) {
// Drop anything we already got from the list
indexes_and_extensions.erase(completed);
}
for (auto& index_and_extensions : indexes_and_extensions) {
for (auto index_and_extensions = indexes_and_extensions.begin(); index_and_extensions != indexes_and_extensions.end(); ) {
// For each index type
for (auto& extension : index_and_extensions.second) {
bool found = false;
for (auto& extension : index_and_extensions->second) {
// For each extension in priority order
string inferred_filename = registry.get_prefix() + "." + extension;
if (ifstream(inferred_filename).is_open()) {
Expand All @@ -1636,14 +1638,21 @@ int main_giraffe(int argc, char** argv) {
cerr << "warning:[vg giraffe] " << inferred_filename << " exists and will be overwritten" << endl;
} else {
// Report it because this may not be desired behavior.
cerr << "Guessing that " << inferred_filename << " is " << index_and_extensions.first << endl;
registry.provide(index_and_extensions.first, inferred_filename);
indexes_and_extensions.erase(index_and_extensions.first);
cerr << "Guessing that " << inferred_filename << " is " << index_and_extensions->first << endl;
registry.provide(index_and_extensions->first, inferred_filename);
found = true;
}
// Skip other extension options for the index
break;
}
}
if (found) {
// Erase this one and go to the next one.
index_and_extensions = indexes_and_extensions.erase(index_and_extensions);
} else {
// Leave this one and go to the next one.
++index_and_extensions;
}
}

//If we're making new zipcodes, we should rebuild the minimizers too
Expand Down

1 comment on commit 67637a6

@adamnovak
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for branch minimizer-autoindex. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 17208 seconds

Please sign in to comment.