diff options
| author | Igor Anić <igor.anic@gmail.com> | 2024-04-03 17:08:41 +0200 |
|---|---|---|
| committer | Igor Anić <igor.anic@gmail.com> | 2024-04-03 17:08:41 +0200 |
| commit | 24304a43854d62572daab4b5e922bb7436c73c50 (patch) | |
| tree | c723aa9c43e9edc5af8ea6c4882ff8b423d48f0d /src/Package | |
| parent | c4261bf5624d80f1e613bed475ebe03543ec83b8 (diff) | |
| download | zig-24304a43854d62572daab4b5e922bb7436c73c50.tar.gz zig-24304a43854d62572daab4b5e922bb7436c73c50.zip | |
fetch: save syscall, and add comment
From review comments: https://github.com/ziglang/zig/pull/19111
Diffstat (limited to 'src/Package')
| -rw-r--r-- | src/Package/Fetch.zig | 10 |
1 files 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, |
