Skip to content

Commit f8fc127

Browse files
committed
fix stats loading/saving errors
1 parent 17a3fc8 commit f8fc127

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ To install or update LODA, please follow the [installation instructions](https:/
22

33
## [Unreleased]
44

5+
## v23.10.8
6+
7+
### Bugfixes
8+
9+
* Fix errors during loading and saving of stats
10+
511
## v23.9.30
612

713
### Features

src/mine/finder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ void Finder::notifyInvalidMatch(size_t id) {
427427
}
428428
if (scheduler.isTargetReached()) {
429429
scheduler.reset();
430-
Log::get().debug("Saving " + std::to_string(invalid_matches.size()) +
431-
" invalid matches");
430+
Log::get().info("Saving invalid matches stats for " +
431+
std::to_string(invalid_matches.size()) + " sequences");
432432
OeisList::mergeMap(OeisList::INVALID_MATCHES_FILE, invalid_matches);
433433
}
434434
}

src/mine/miner.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ void Miner::mine() {
8686
runMineLoop();
8787
auto mins = std::to_string(monitor->getElapsedSeconds() / 60);
8888
Log::get().info("Finished mining after " + mins + " minutes");
89+
} catch (const std::exception &e) {
90+
Log::get().error(
91+
"Caught exception during mining: " + std::string(e.what()), false);
8992
} catch (...) {
90-
Log::get().error("Caught exception during mining", false);
93+
Log::get().error("Caught unknown exception during mining", false);
9194
}
9295
try {
9396
thread.join();

src/oeis/oeis_list.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,17 @@ void OeisList::mergeMap(const std::string& file_name,
148148
FolderLock lock(getListsHome());
149149
std::ifstream in(getListsHome() + file_name);
150150
if (in.good()) {
151-
addToMap(in, map);
151+
try {
152+
addToMap(in, map);
153+
} catch (...) {
154+
Log::get().warn("Overwriting corrupt data in " + file_name);
155+
}
152156
in.close();
153157
}
154158
std::ofstream out(getListsHome() + file_name);
155159
for (auto it : map) {
156-
out << OeisSequence(it.first).id_str() << ": " << it.second << "\n";
160+
out << OeisSequence(it.first).id_str() << ": " << it.second
161+
<< std::endl; // flush at every line to avoid corrupt data
157162
}
158163
out.close();
159164
map.clear();

0 commit comments

Comments
 (0)