From 3e234396bf69b9fa5ba178db40d0501255a728e7 Mon Sep 17 00:00:00 2001 From: MrBounty Date: Wed, 12 Feb 2025 14:52:48 +0100 Subject: [PATCH] Fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now delete .new file if Йfind one when I shouldn't in allFileIndex --- src/file/utils.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/file/utils.zig b/src/file/utils.zig index bcd2af4..4188828 100644 --- a/src/file/utils.zig +++ b/src/file/utils.zig @@ -164,7 +164,11 @@ pub fn allFileIndex(self: Self, allocator: Allocator, struct_name: []const u8) Z var iter = dir.iterate(); while (iter.next() catch return ZipponError.DirIterError) |entry| { if (entry.kind != .file) continue; - if (std.mem.eql(u8, entry.name[0..(entry.name.len - 4)], ".new")) continue; // TODO: Delete the file, shouldn't be here + if (std.mem.eql(u8, entry.name[0..(entry.name.len - 4)], ".new")) { + dir.deleteFile(entry.name) catch return ZipponError.DeleteFileError; + continue; + } + const index = std.fmt.parseInt(usize, entry.name[0..(entry.name.len - 4)], 10) catch return ZipponError.InvalidFileIndex; array.append(index) catch return ZipponError.MemoryError; }