mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-10-24 23:33:47 +08:00
frontend: Change crash sentinel location to separate subdirectory
Putting the crash sentinel in the main "obs-studio" directory carries the risk of unwanted deletion of files in the same directory, which usually contains user configuration files like "user.ini" and "global.ini". Even though the code will ignore any file that does not start with the crash sentinel prefix string, the code itself would allow changing the prefix to "global.ini" and thus inadvertently delete the global configuration file as well. To further reduce the risk, this change will put the sentinels in a separate sub-directory that should only ever contain sentinel files, all of which can possibly deleted without any data loss for the user.
This commit is contained in:
@@ -33,8 +33,8 @@ using CrashLogUpdateResult = OBS::CrashHandler::CrashLogUpdateResult;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::string_view crashSentinelPath = "obs-studio";
|
||||
constexpr std::string_view crashSentinelPrefix = "crash_sentinel_";
|
||||
constexpr std::string_view crashSentinelPath = "obs-studio/.sentinel";
|
||||
constexpr std::string_view crashSentinelPrefix = "run_";
|
||||
constexpr std::string_view crashUploadURL = "https://obsproject.com/logs/upload";
|
||||
|
||||
#ifndef NDEBUG
|
||||
@@ -190,8 +190,14 @@ void CrashHandler::checkCrashState()
|
||||
std::filesystem::path crashSentinelPath = crashSentinelFile_.parent_path();
|
||||
|
||||
if (!std::filesystem::exists(crashSentinelPath)) {
|
||||
blog(LOG_ERROR, "Crash sentinel location '%s' does not exist", crashSentinelPath.u8string().c_str());
|
||||
return;
|
||||
try {
|
||||
std::filesystem::create_directory(crashSentinelPath);
|
||||
} catch (const std::filesystem::filesystem_error &error) {
|
||||
blog(LOG_ERROR,
|
||||
"Crash sentinel location '%s' does not exist and unable to create directory:\n%s.",
|
||||
crashSentinelPath.u8string().c_str(), error.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &entry : std::filesystem::directory_iterator(crashSentinelPath)) {
|
||||
|
||||
Reference in New Issue
Block a user