diff options
| author | Lee Cannon <leecannon@leecannon.xyz> | 2022-01-07 18:02:43 +0000 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-07 16:50:37 -0500 |
| commit | 1cdc51ec1012bc2a6d1c115eaaeb24a2a93c26c5 (patch) | |
| tree | 07c7bef95f4b5d5ef303f230c64751c6088a53b1 /src | |
| parent | dd076d8cba226409a00813f3477f55fd2e0eb6e6 (diff) | |
| download | zig-1cdc51ec1012bc2a6d1c115eaaeb24a2a93c26c5.tar.gz zig-1cdc51ec1012bc2a6d1c115eaaeb24a2a93c26c5.zip | |
handle `error.PathAlreadyExists` in `renameTmpIntoCache`
Diffstat (limited to 'src')
| -rw-r--r-- | src/link.zig | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/link.zig b/src/link.zig index 422d86d4b3..7acb8e9af6 100644 --- a/src/link.zig +++ b/src/link.zig @@ -672,12 +672,21 @@ pub const File = struct { // is not needed we can refactor this into having the frontend do the rename // directly, and remove this function from link.zig. _ = base; - try std.fs.rename( - cache_directory.handle, - tmp_dir_sub_path, - cache_directory.handle, - o_sub_path, - ); + while (true) { + std.fs.rename( + cache_directory.handle, + tmp_dir_sub_path, + cache_directory.handle, + o_sub_path, + ) catch |err| switch (err) { + error.PathAlreadyExists => { + try cache_directory.handle.deleteTree(o_sub_path); + continue; + }, + else => |e| return e, + }; + break; + } } pub fn linkAsArchive(base: *File, comp: *Compilation) !void { |
