fix(core): Add action journal exception handling (#4438)

This commit is contained in:
Adrian Cojocaru
2026-08-04 19:34:45 +03:00
committed by GitHub
parent e626fc0fbd
commit f1905c5215

View File

@@ -148,11 +148,21 @@ ActionJournal::Impl::Impl(const Map& map_, const ActionJournalOptions& options_)
previousFrameTime = util::MonotonicTimer::now().count();
options.withPath((mbgl::filesystem::canonical(options.path()) / ACTION_JOURNAL_DIRECTORY_NAME).generic_string());
try {
options.withPath(
(mbgl::filesystem::weakly_canonical(options.path()) / ACTION_JOURNAL_DIRECTORY_NAME).generic_string());
if (!openFile(detectFiles(), false)) {
Log::Error(Event::General, "Failed to open Action Journal file");
if (!openFile(detectFiles(), false)) {
Log::Error(Event::General, "Failed to open Action Journal file");
}
} catch (const mbgl::filesystem::filesystem_error& e) {
Log::Error(Event::General, std::string("Action Journal file exception: ") + e.what());
} catch (...) {
Log::Error(Event::General, std::string("Action Journal exception: ") + toString(std::current_exception()));
}
scheduler->setExceptionHandler(
[](const std::exception_ptr e) { Log::Error(Event::General, "Action Journal log exception: " + toString(e)); });
}
ActionJournal::Impl::~Impl() {
@@ -589,7 +599,14 @@ bool ActionJournal::Impl::openFile(uint32_t fileIndex, bool truncate) {
}
bool ActionJournal::Impl::prepareFile(size_t size) {
if (currentFileSize + size <= options.logFileSize() && currentFile) {
if (!currentFile) {
if (!openFile(detectFiles(), false)) {
Log::Error(Event::General, "Failed to open Action Journal file");
return false;
}
}
if (currentFileSize + size <= options.logFileSize()) {
currentFileSize += size;
return true;
}