fix: don't restore files from project that no longer exist

This commit is contained in:
CJ van den Berg 2025-10-23 19:02:29 +02:00
parent 4c156aa4b1
commit 5b23998376
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -197,9 +197,12 @@ pub fn restore_state_v1(self: *Self, data: []const u8) !void {
} }
tp.trace(tp.channel.debug, .{ "restore_state_v1", "file", path, mtime, row, col }); tp.trace(tp.channel.debug, .{ "restore_state_v1", "file", path, mtime, row, col });
self.longest_file_path = @max(self.longest_file_path, path.len); self.longest_file_path = @max(self.longest_file_path, path.len);
const stat = std.fs.cwd().statFile(path) catch { const stat = std.fs.cwd().statFile(path) catch |e| switch (e) {
error.FileNotFound => continue,
else => {
try self.update_mru_internal(path, mtime, row, col); try self.update_mru_internal(path, mtime, row, col);
continue; continue;
},
}; };
switch (stat.kind) { switch (stat.kind) {
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col), .sym_link, .file => try self.update_mru_internal(path, mtime, row, col),
@ -264,9 +267,12 @@ pub fn restore_state_v0(self: *Self, data: []const u8) error{
}) { }) {
tp.trace(tp.channel.debug, .{ "restore_state_v0", "file", path, mtime, row, col }); tp.trace(tp.channel.debug, .{ "restore_state_v0", "file", path, mtime, row, col });
self.longest_file_path = @max(self.longest_file_path, path.len); self.longest_file_path = @max(self.longest_file_path, path.len);
const stat = std.fs.cwd().statFile(path) catch { const stat = std.fs.cwd().statFile(path) catch |e| switch (e) {
error.FileNotFound => continue,
else => {
try self.update_mru_internal(path, mtime, row, col); try self.update_mru_internal(path, mtime, row, col);
continue; continue;
},
}; };
switch (stat.kind) { switch (stat.kind) {
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col), .sym_link, .file => try self.update_mru_internal(path, mtime, row, col),