commit 24304a43854d62572daab4b5e922bb7436c73c50 (tree)
parent c4261bf5624d80f1e613bed475ebe03543ec83b8
Author: Igor Anić <igor.anic@gmail.com>
Date: Wed, 3 Apr 2024 17:08:41 +0200
fetch: save syscall, and add comment
From review comments: https://github.com/ziglang/zig/pull/19111
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git 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,