authorgravatar for leecannon@leecannon.xyzLee Cannon <leecannon@leecannon.xyz> 2022-01-07 18:02:43+00:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-07 16:50:37-05:00
log1cdc51ec1012bc2a6d1c115eaaeb24a2a93c26c5
tree07c7bef95f4b5d5ef303f230c64751c6088a53b1
parentdd076d8cba226409a00813f3477f55fd2e0eb6e6

handle `error.PathAlreadyExists` in `renameTmpIntoCache`


1 files changed, 15 insertions(+), 6 deletions(-)

src/link.zig+15-6
......@@ -672,12 +672,21 @@ pub const File = struct {
672672 // is not needed we can refactor this into having the frontend do the rename
673673 // directly, and remove this function from link.zig.
674674 _ = base;
675 try std.fs.rename(
676 cache_directory.handle,
677 tmp_dir_sub_path,
678 cache_directory.handle,
679 o_sub_path,
680 );
675 while (true) {
676 std.fs.rename(
677 cache_directory.handle,
678 tmp_dir_sub_path,
679 cache_directory.handle,
680 o_sub_path,
681 ) catch |err| switch (err) {
682 error.PathAlreadyExists => {
683 try cache_directory.handle.deleteTree(o_sub_path);
684 continue;
685 },
686 else => |e| return e,
687 };
688 break;
689 }
681690 }
682691
683692 pub fn linkAsArchive(base: *File, comp: *Compilation) !void {