Compare commits

..

No commits in common. "78cc4b2d24c8d75d2f4d9dc5c4b74e1b5b677a35" and "983c4844badd7820f5f5b6d2f3dbb1bed215e438" have entirely different histories.

2 changed files with 7 additions and 18 deletions

View file

@ -196,10 +196,7 @@ pub fn restore_state_v1(self: *Self, data: []const u8) !void {
}
tp.trace(tp.channel.debug, .{ "restore_state_v1", "file", path, mtime, row, col });
self.longest_file_path = @max(self.longest_file_path, path.len);
const stat = std.fs.cwd().statFile(path) catch {
try self.update_mru_internal(path, mtime, row, col);
continue;
};
const stat = std.fs.cwd().statFile(path) catch continue;
switch (stat.kind) {
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col),
else => {},
@ -263,10 +260,7 @@ pub fn restore_state_v0(self: *Self, data: []const u8) error{
}) {
tp.trace(tp.channel.debug, .{ "restore_state_v0", "file", path, mtime, row, col });
self.longest_file_path = @max(self.longest_file_path, path.len);
const stat = std.fs.cwd().statFile(path) catch {
try self.update_mru_internal(path, mtime, row, col);
continue;
};
const stat = std.fs.cwd().statFile(path) catch continue;
switch (stat.kind) {
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col),
else => {},
@ -2070,16 +2064,14 @@ pub fn process_git(self: *Self, parent: tp.pid_ref, m: tp.message) (OutOfMemoryE
try self.loaded(parent);
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.extract(&path) })) {
self.longest_file_path = @max(self.longest_file_path, path.len);
const mtime: i128 = blk: {
break :blk (std.fs.cwd().statFile(path) catch break :blk 0).mtime;
};
const stat = std.fs.cwd().statFile(path) catch return;
const file_type: []const u8, const file_icon: []const u8, const file_color: u24 = guess_file_type(path);
(try self.pending.addOne(self.allocator)).* = .{
.path = try self.allocator.dupe(u8, path),
.type = file_type,
.icon = file_icon,
.color = file_color,
.mtime = mtime,
.mtime = stat.mtime,
};
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.null_ })) {
self.state.workspace_files = .done;

View file

@ -1423,12 +1423,9 @@ pub const StoreToFileError = error{
};
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
var atomic = blk: {
const stat = try cwd().statFile(file_path);
var write_buffer: [4096]u8 = undefined;
const stat = cwd().statFile(file_path) catch
break :blk try cwd().atomicFile(file_path, .{ .write_buffer = &write_buffer });
break :blk try cwd().atomicFile(file_path, .{ .mode = stat.mode, .write_buffer = &write_buffer });
};
var atomic = try cwd().atomicFile(file_path, .{ .mode = stat.mode, .write_buffer = &write_buffer });
defer atomic.deinit();
try self.store_to_file_const(&atomic.file_writer.interface);
try atomic.finish();