fix: Project stuck in loading state

This commit is contained in:
CJ van den Berg 2025-11-08 22:29:49 +01:00
parent b5437533f3
commit f909e1437e
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -49,6 +49,7 @@ state: struct {
status: VcsStatus = .{}, status: VcsStatus = .{},
status_request: ?tp.pid = null, status_request: ?tp.pid = null,
load_complete: bool = false,
const Self = @This(); const Self = @This();
@ -624,6 +625,9 @@ fn loaded(self: *Self, parent: tp.pid_ref) OutOfMemoryError!void {
inline for (@typeInfo(@TypeOf(self.state)).@"struct".fields) |f| inline for (@typeInfo(@TypeOf(self.state)).@"struct".fields) |f|
if (@field(self.state, f.name) == .running) return; if (@field(self.state, f.name) == .running) return;
if (self.load_complete) return;
self.load_complete = true;
self.logger.print("project files: {d} restored, {d} {s}", .{ self.logger.print("project files: {d} restored, {d} {s}", .{
self.files.items.len, self.files.items.len,
self.pending.items.len, self.pending.items.len,
@ -2232,7 +2236,7 @@ pub fn process_git(self: *Self, parent: tp.pid_ref, m: tp.message) (OutOfMemoryE
var path: []const u8 = undefined; var path: []const u8 = undefined;
var vcs_status: u8 = undefined; var vcs_status: u8 = undefined;
if (try m.match(.{ tp.any, tp.any, "status", tp.more })) { if (try m.match(.{ tp.any, tp.any, "status", tp.more })) {
return self.process_status(m); return self.process_status(parent, m);
} else if (try m.match(.{ tp.any, tp.any, "workspace_path", tp.null_ })) { } else if (try m.match(.{ tp.any, tp.any, "workspace_path", tp.null_ })) {
self.state.workspace_path = .done; self.state.workspace_path = .done;
self.start_walker(); self.start_walker();
@ -2287,7 +2291,7 @@ pub fn process_git(self: *Self, parent: tp.pid_ref, m: tp.message) (OutOfMemoryE
} }
} }
fn process_status(self: *Self, m: tp.message) (OutOfMemoryError || error{Exit})!void { fn process_status(self: *Self, parent: tp.pid_ref, m: tp.message) (OutOfMemoryError || error{Exit})!void {
const any = cbor.any; const any = cbor.any;
const extract = cbor.extract; const extract = cbor.extract;
const null_ = cbor.null_; const null_ = cbor.null_;
@ -2330,6 +2334,7 @@ fn process_status(self: *Self, m: tp.message) (OutOfMemoryError || error{Exit})!
// ignored file: <path> // ignored file: <path>
} else if (try m.match(.{ any, any, "status", null_ })) { } else if (try m.match(.{ any, any, "status", null_ })) {
self.state.status = .done; self.state.status = .done;
try self.loaded(parent);
if (self.status_request) |from| { if (self.status_request) |from| {
from.send(.{ "vcs_status", self.status }) catch {}; from.send(.{ "vcs_status", self.status }) catch {};
from.deinit(); from.deinit();