mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Use bundle ID for macOS cache directory path
This commit is contained in:
@ -102,7 +102,7 @@ fn initThread(gpa: Allocator) !void {
|
|||||||
|
|
||||||
// Determine the Sentry cache directory.
|
// Determine the Sentry cache directory.
|
||||||
const cache_dir = if (builtin.os.tag == .macos)
|
const cache_dir = if (builtin.os.tag == .macos)
|
||||||
try internal_os.macos.cacheDir(alloc, "ghostty/sentry")
|
try internal_os.macos.cacheDir(alloc, "sentry")
|
||||||
else
|
else
|
||||||
try internal_os.xdg.cache(alloc, .{ .subdir = "ghostty/sentry" });
|
try internal_os.xdg.cache(alloc, .{ .subdir = "ghostty/sentry" });
|
||||||
sentry.c.sentry_options_set_database_path_n(
|
sentry.c.sentry_options_set_database_path_n(
|
||||||
|
@ -39,7 +39,10 @@ pub fn cacheDir(
|
|||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
sub_path: []const u8,
|
sub_path: []const u8,
|
||||||
) CacheDirError![]const u8 {
|
) CacheDirError![]const u8 {
|
||||||
return try makeCommonPath(alloc, .NSCachesDirectory, &.{sub_path});
|
return try makeCommonPath(alloc, .NSCachesDirectory, &.{
|
||||||
|
build_config.bundle_id,
|
||||||
|
sub_path,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const SetQosClassError = error{
|
pub const SetQosClassError = error{
|
||||||
@ -150,14 +153,19 @@ test "cacheDir paths" {
|
|||||||
{
|
{
|
||||||
const cache_path = try cacheDir(alloc, "");
|
const cache_path = try cacheDir(alloc, "");
|
||||||
defer alloc.free(cache_path);
|
defer alloc.free(cache_path);
|
||||||
// We don't test the exact path since it comes from NSFileManager
|
|
||||||
try testing.expect(std.mem.indexOf(u8, cache_path, "Caches") != null);
|
try testing.expect(std.mem.indexOf(u8, cache_path, "Caches") != null);
|
||||||
|
try testing.expect(std.mem.indexOf(u8, cache_path, build_config.bundle_id) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test with subdir
|
// Test with subdir
|
||||||
{
|
{
|
||||||
const cache_path = try cacheDir(alloc, "ghostty");
|
const cache_path = try cacheDir(alloc, "test");
|
||||||
defer alloc.free(cache_path);
|
defer alloc.free(cache_path);
|
||||||
try testing.expect(std.mem.indexOf(u8, cache_path, "Caches/ghostty") != null);
|
try testing.expect(std.mem.indexOf(u8, cache_path, "Caches") != null);
|
||||||
|
try testing.expect(std.mem.indexOf(u8, cache_path, build_config.bundle_id) != null);
|
||||||
|
|
||||||
|
const bundle_path = try std.fmt.allocPrint(alloc, "{s}/test", .{build_config.bundle_id});
|
||||||
|
defer alloc.free(bundle_path);
|
||||||
|
try testing.expect(std.mem.indexOf(u8, cache_path, bundle_path) != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user