Skip to content

Commit f4d6b37

Browse files
committed
Package: handle Windows PathAlreadyExists error code
Unfortunately, error.AccessDenied is ambiguous on Windows when it is returned from fs.rename.
1 parent 2de0863 commit f4d6b37

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/std/os.zig

+3
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,9 @@ pub fn unlinkatW(dirfd: fd_t, sub_path_w: []const u16, flags: u32) UnlinkatError
24142414
pub const RenameError = error{
24152415
/// In WASI, this error may occur when the file descriptor does
24162416
/// not hold the required rights to rename a resource by path relative to it.
2417+
///
2418+
/// On Windows, this error may be returned instead of PathAlreadyExists when
2419+
/// renaming a directory over an existing directory.
24172420
AccessDenied,
24182421
FileBusy,
24192422
DiskQuota,

src/Package.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ fn renameTmpIntoCache(
570570
};
571571
continue;
572572
},
573-
error.PathAlreadyExists => {
573+
error.PathAlreadyExists, error.AccessDenied => {
574574
// Package has been already downloaded and may already be in use on the system.
575575
cache_dir.deleteTree(tmp_dir_sub_path) catch |del_err| {
576576
std.log.warn("unable to delete temp directory: {s}", .{@errorName(del_err)});

0 commit comments

Comments
 (0)