Skip to content

Commit

Permalink
Fixes atomicSymLink looping when new_path already exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikskuh authored and andrewrk committed Jul 28, 2020
1 parent d726c2a commit 606b646
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/std/fs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path:
try crypto.randomBytes(rand_buf[0..]);
base64_encoder.encode(tmp_path[dirname.len + 1 ..], &rand_buf);

if (cwd().symLink(existing_path, new_path, .{})) {
if (cwd().symLink(existing_path, tmp_path, .{})) {
return rename(tmp_path, new_path);
} else |err| switch (err) {
error.PathAlreadyExists => continue,
Expand Down

0 comments on commit 606b646

Please sign in to comment.