authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-03 17:08:41+02:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-03 17:08:41+02:00
log24304a43854d62572daab4b5e922bb7436c73c50
treec723aa9c43e9edc5af8ea6c4882ff8b423d48f0d
parentc4261bf5624d80f1e613bed475ebe03543ec83b8

fetch: save syscall, and add comment

From review comments: https://github.com/ziglang/zig/pull/19111

1 files changed, 8 insertions(+), 2 deletions(-)

src/Package/Fetch.zig+8-2
......@@ -532,8 +532,10 @@ fn runResource(
532532 ) });
533533 return error.FetchFailed;
534534 };
535 // Remove temporary directory root.
536 cache_root.handle.deleteTree(tmp_dir_sub_path) catch {};
535 // Remove temporary directory root if not already renamed to cache.
536 if (!std.mem.eql(u8, package_sub_path, tmp_dir_sub_path)) {
537 cache_root.handle.deleteDir(tmp_dir_sub_path) catch {};
538 }
537539
538540 // Validate the computed hash against the expected hash. If invalid, this
539541 // job is done.
......@@ -1059,6 +1061,10 @@ fn initResource(f: *Fetch, uri: std.Uri, server_header_buffer: []u8) RunError!Re
10591061 ));
10601062}
10611063
1064/// A `null` return value indicates the `tmp_directory` is populated directly
1065/// with the package contents.
1066/// A non-null return value means that the package contents are inside a
1067/// sub-directory indicated by the named path.
10621068fn unpackResource(
10631069 f: *Fetch,
10641070 resource: *Resource,