diff options
| author | thejch <66577496+thejch@users.noreply.github.com> | 2024-02-19 16:55:04 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-20 00:55:04 +0000 |
| commit | 030ed27cc8dee5712f5d38dff9af0b1b3a97bd9c (patch) | |
| tree | 361db2c68e6d35725a0d6a5957306c1a7e580154 | |
| parent | e793f10b8bd1685a2e2bbd7cc90063f12bf380c4 (diff) | |
crashreporter: Use ~/.cache as cache dir (#4719)
* use ~/.cache for crash reports
* minor word edit
* clang-format
* minor typo
| -rw-r--r-- | docs/ISSUE_GUIDELINES.md | 2 | ||||
| -rw-r--r-- | src/debug/CrashReporter.cpp | 21 |
2 files changed, 10 insertions, 13 deletions
diff --git a/docs/ISSUE_GUIDELINES.md b/docs/ISSUE_GUIDELINES.md index be011608..c031fe85 100644 --- a/docs/ISSUE_GUIDELINES.md +++ b/docs/ISSUE_GUIDELINES.md @@ -47,7 +47,7 @@ basically, directories in /tmp/hypr are your sessions. ## Obtaining the Hyprland Crash Report (v0.22.0beta and up) -If you have `$XDG_CACHE_HOME` set, the crash report directory is `$XDG_CACHE_HOME/hyprland`. If not, it's `~/.hyprland` +If you have `$XDG_CACHE_HOME` set, the crash report directory is `$XDG_CACHE_HOME/hyprland`. If not, it's `$HOME/.cache/hyprland`. Go to the crash report directory and you should find a file named `hyprlandCrashReport[XXXX].txt` where `[XXXX]` is the PID of the process that crashed. diff --git a/src/debug/CrashReporter.cpp b/src/debug/CrashReporter.cpp index 70a6f7b6..cf648191 100644 --- a/src/debug/CrashReporter.cpp +++ b/src/debug/CrashReporter.cpp @@ -146,21 +146,18 @@ void CrashReporter::createAndSaveCrash(int sig) { return; std::ofstream ofs; - std::string path; - if (!CACHE_HOME || std::string(CACHE_HOME).empty()) { - if (!std::filesystem::exists(std::string(HOME) + "/.hyprland")) - std::filesystem::create_directory(std::string(HOME) + "/.hyprland"); + std::string reportDir; - path = std::string(HOME) + "/.hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt"; - ofs.open(path, std::ios::trunc); + if (!CACHE_HOME || std::string(CACHE_HOME).empty()) + reportDir = std::string(HOME) + "/.cache/hyprland"; + else + reportDir = std::string(CACHE_HOME) + "/hyprland"; - } else { - if (!std::filesystem::exists(std::string(CACHE_HOME) + "/hyprland")) - std::filesystem::create_directory(std::string(CACHE_HOME) + "/hyprland"); + if (!std::filesystem::exists(reportDir)) + std::filesystem::create_directory(reportDir); + const auto path = reportDir + "/hyprlandCrashReport" + std::to_string(PID) + ".txt"; - path = std::string(CACHE_HOME) + "/hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt"; - ofs.open(path, std::ios::trunc); - } + ofs.open(path, std::ios::trunc); ofs << finalCrashReport; |
