diff --git a/src/mbgl/util/action_journal_impl.cpp b/src/mbgl/util/action_journal_impl.cpp index fe1669811..b66de4fcc 100644 --- a/src/mbgl/util/action_journal_impl.cpp +++ b/src/mbgl/util/action_journal_impl.cpp @@ -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; }