mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-15 14:26:09 +00:00
crash: prefer XDG cache dir if available
This commit is contained in:
@@ -101,10 +101,23 @@ fn initThread(gpa: Allocator) !void {
|
||||
sentry.c.sentry_options_set_before_send(opts, beforeSend, null);
|
||||
|
||||
// Determine the Sentry cache directory.
|
||||
const cache_dir = if (builtin.os.tag == .macos)
|
||||
try internal_os.macos.cacheDir(alloc, "sentry")
|
||||
else
|
||||
try internal_os.xdg.cache(alloc, .{ .subdir = "ghostty/sentry" });
|
||||
const cache_dir = cache_dir: {
|
||||
// On macOS, we prefer to use the NSCachesDirectory value to be
|
||||
// a more idiomatic macOS application. But if XDG env vars are set
|
||||
// we will respect them.
|
||||
if (comptime builtin.os.tag == .macos) macos: {
|
||||
if (std.posix.getenv("XDG_CACHE_HOME") != null) break :macos;
|
||||
break :cache_dir try internal_os.macos.cacheDir(
|
||||
alloc,
|
||||
"sentry",
|
||||
);
|
||||
}
|
||||
|
||||
break :cache_dir try internal_os.xdg.cache(
|
||||
alloc,
|
||||
.{ .subdir = "ghostty/sentry" },
|
||||
);
|
||||
};
|
||||
sentry.c.sentry_options_set_database_path_n(
|
||||
opts,
|
||||
cache_dir.ptr,
|
||||
|
Reference in New Issue
Block a user