zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f4d6b37068db7ef3b5828dbe2403e65bf64a0f2c (tree)
parent 2de08633800cd458fa657afed25a821236520cd8
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 11 Jan 2023 17:54:34 -0800

Package: handle Windows PathAlreadyExists error code

Unfortunately, error.AccessDenied is ambiguous on Windows when it is
returned from fs.rename.

Diffstat:
Mlib/std/os.zig | 3+++
Msrc/Package.zig | 2+-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/std/os.zig b/lib/std/os.zig @@ -2414,6 +2414,9 @@ pub fn unlinkatW(dirfd: fd_t, sub_path_w: []const u16, flags: u32) UnlinkatError pub const RenameError = error{ /// In WASI, this error may occur when the file descriptor does /// not hold the required rights to rename a resource by path relative to it. + /// + /// On Windows, this error may be returned instead of PathAlreadyExists when + /// renaming a directory over an existing directory. AccessDenied, FileBusy, DiskQuota, diff --git a/src/Package.zig b/src/Package.zig @@ -570,7 +570,7 @@ fn renameTmpIntoCache( }; continue; }, - error.PathAlreadyExists => { + error.PathAlreadyExists, error.AccessDenied => { // Package has been already downloaded and may already be in use on the system. cache_dir.deleteTree(tmp_dir_sub_path) catch |del_err| { std.log.warn("unable to delete temp directory: {s}", .{@errorName(del_err)});