From 24304a43854d62572daab4b5e922bb7436c73c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Anic=CC=81?= Date: Wed, 3 Apr 2024 17:08:41 +0200 Subject: [PATCH] fetch: save syscall, and add comment From review comments: https://github.com/ziglang/zig/pull/19111 --- src/Package/Fetch.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig index 02afc70b7f..9abf0dceb7 100644 --- a/src/Package/Fetch.zig +++ b/src/Package/Fetch.zig @@ -532,8 +532,10 @@ fn runResource( ) }); return error.FetchFailed; }; - // Remove temporary directory root. - cache_root.handle.deleteTree(tmp_dir_sub_path) catch {}; + // Remove temporary directory root if not already renamed to cache. + if (!std.mem.eql(u8, package_sub_path, tmp_dir_sub_path)) { + cache_root.handle.deleteDir(tmp_dir_sub_path) catch {}; + } // Validate the computed hash against the expected hash. If invalid, this // job is done. @@ -1059,6 +1061,10 @@ fn initResource(f: *Fetch, uri: std.Uri, server_header_buffer: []u8) RunError!Re )); } +/// A `null` return value indicates the `tmp_directory` is populated directly +/// with the package contents. +/// A non-null return value means that the package contents are inside a +/// sub-directory indicated by the named path. fn unpackResource( f: *Fetch, resource: *Resource,