Skip to content

Commit

Permalink
Do not treat FileNotFound as error when cleaning up segment file
Browse files Browse the repository at this point in the history
  • Loading branch information
lalinsky committed Dec 7, 2024
1 parent 7f5513d commit 54e022d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/FileSegment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ pub fn delete(self: *Self) void {
log.info("deleting segment file {s}", .{file_name});

self.dir.deleteFile(file_name) catch |err| {
log.err("failed to clean up segment file {s}: {}", .{ file_name, err });
if (err != error.FileNotFound) {
log.err("failed to clean up segment file {s}: {}", .{ file_name, err });
}
};
}

Expand All @@ -126,7 +128,9 @@ pub fn build(self: *Self, source: anytype) !void {
try filefmt.writeSegmentFile(self.dir, source);

errdefer self.dir.deleteFile(file_name) catch |err| {
log.err("failed to clean up segment file {s}: {}", .{ file_name, err });
if (err != error.FileNotFound) {
log.err("failed to clean up segment file {s}: {}", .{ file_name, err });
}
};

try filefmt.readSegmentFile(self.dir, source.segment.info, self);
Expand Down

0 comments on commit 54e022d

Please sign in to comment.