feat(tabs): don't write tab styles config if it doesn't already exist

This commit is contained in:
CJ van den Berg 2025-01-30 13:14:00 +01:00
parent 8eb536b5b9
commit 2371140b3f
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 15 additions and 2 deletions

View file

@ -406,6 +406,16 @@ pub fn free_config(allocator: std.mem.Allocator, bufs: [][]const u8) void {
var config_mutex: std.Thread.Mutex = .{};
pub fn exists_config(T: type) bool {
config_mutex.lock();
defer config_mutex.unlock();
const json_file_name = get_app_config_file_name(application_name, @typeName(T)) catch return false;
const text_file_name = json_file_name[0 .. json_file_name.len - ".json".len];
var file = std.fs.openFileAbsolute(text_file_name, .{ .mode = .read_only }) catch return false;
defer file.close();
return true;
}
pub fn read_config(T: type, allocator: std.mem.Allocator) struct { T, [][]const u8 } {
config_mutex.lock();
defer config_mutex.unlock();