Simplify Sentry::areThereCrashesToReport() using sentry_get_crashed_last_run()

Thanks for the Sentry team for the help in:
https://github.com/getsentry/sentry-native/issues/930
This commit is contained in:
David Capello 2024-01-08 14:08:25 -03:00
parent 78f5560b33
commit 00894101e0

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2021-2023 Igara Studio S.A.
// Copyright (C) 2021-2024 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -97,26 +97,9 @@ bool Sentry::areThereCrashesToReport()
if (m_dbdir.empty())
return false;
// If the last_crash file exists, we can say that there are
// something to report (this file is created on Windows and Linux).
if (base::is_file(base::join_path(m_dbdir, "last_crash")))
return true;
// At least one .dmp file in the completed/ directory means that
// there was at least one crash in the past (this is for macOS).
for (auto f : base::list_files(base::join_path(m_dbdir, "completed"))) {
if (base::get_file_extension(f) == "dmp")
return true;
}
// In case that "last_crash" doesn't exist we can check for some
// .dmp file in the reports/ directory (it looks like the completed/
// directory is not generated on Windows).
for (auto f : base::list_files(base::join_path(m_dbdir, "reports"))) {
if (base::get_file_extension(f) == "dmp")
return true;
}
return false;
// As we don't use sentry_clear_crashed_last_run(), this will
// return 1 if the last run (or any previous run) has crashed.
return (sentry_get_crashed_last_run() == 1);
}
// static