refactor: add file watcher to project_manager and watch project

This commit is contained in:
CJ van den Berg 2026-02-20 11:39:54 +01:00
parent 94cdf4503e
commit bf0ef280ce
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -3,6 +3,7 @@ const tp = @import("thespian");
const cbor = @import("cbor");
const log = @import("log");
const tracy = @import("tracy");
const file_watcher = @import("file_watcher");
const file_type_config = @import("file_type_config");
const lsp_config = @import("lsp_config");
const root = @import("soft_root").root;
@ -520,6 +521,7 @@ const Process = struct {
self.logger.print("{s} error: {s}", .{ tag, message });
} else if (try cbor.match(m.buf, .{"shutdown"})) {
self.persist_projects();
file_watcher.shutdown();
from.send(.{ "project_manager", "shutdown" }) catch return error.ClientFailed;
return error.ExitNormal;
} else if (try cbor.match(m.buf, .{ "exit", "normal" })) {
@ -548,6 +550,7 @@ const Process = struct {
try self.projects.put(self.allocator, try self.allocator.dupe(u8, project_directory), project);
self.restore_project(project) catch |e| self.logger.err("restore_project", e);
project.query_git();
file_watcher.watch(project_directory) catch |e| self.logger.err("file_watcher.watch", e);
}
}
@ -558,6 +561,7 @@ const Process = struct {
kv.value.deinit();
self.allocator.destroy(kv.value);
self.logger.print("closed: {s}", .{project_directory});
file_watcher.unwatch(project_directory) catch |e| self.logger.err("file_watcher.unwatch", e);
}
}