fix: prevent duplicate files in project file index

This commit is contained in:
CJ van den Berg 2026-02-20 19:02:37 +01:00
parent 5988ff69d4
commit ca0a1c69a5
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -784,6 +784,8 @@ fn loaded(self: *Self, parent: tp.pid_ref) OutOfMemoryError!void {
pub fn file_added(self: *Self, file_path: []const u8) OutOfMemoryError!void { pub fn file_added(self: *Self, file_path: []const u8) OutOfMemoryError!void {
for (self.files.items) |file| for (self.files.items) |file|
if (std.mem.eql(u8, file.path, file_path)) return; if (std.mem.eql(u8, file.path, file_path)) return;
for (self.pending.items) |file|
if (std.mem.eql(u8, file.path, file_path)) return;
const file_type, const file_icon, const file_color = guess_file_type(file_path); const file_type, const file_icon, const file_color = guess_file_type(file_path);
(try self.files.addOne(self.allocator)).* = .{ (try self.files.addOne(self.allocator)).* = .{
.path = try self.allocator.dupe(u8, file_path), .path = try self.allocator.dupe(u8, file_path),