authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-03 21:17:57+02:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-03 21:17:57+02:00
log363acf49910bbc0ff2b8acecea027f3f17bbce25
treec5b639eb013f6c8d57b4bd7f787781975dd34484
parent1431e34cb9e3af8d4437ca2e5f91b6da53be5a47

fetch: update comments


1 files changed, 16 insertions(+), 13 deletions(-)

src/Package/Fetch.zig+16-13
...@@ -461,14 +461,16 @@ fn runResource(...@@ -461,14 +461,16 @@ fn runResource(
461 };461 };
462 defer tmp_directory.handle.close();462 defer tmp_directory.handle.close();
463463
464 // Unpack resource into tmp_directory. A non-null return value means
465 // that the package contents are inside a `pkg_dir` sub-directory.
464 const pkg_dir = try unpackResource(f, resource, uri_path, tmp_directory);466 const pkg_dir = try unpackResource(f, resource, uri_path, tmp_directory);
465467
466 var pkg_path: Cache.Path = if (pkg_dir) |pkg_dir_name|468 var pkg_path: Cache.Path = .{
467 .{ .root_dir = tmp_directory, .sub_path = pkg_dir_name }469 .root_dir = tmp_directory,
468 else470 .sub_path = if (pkg_dir) |pkg_dir_name| pkg_dir_name else "",
469 .{ .root_dir = tmp_directory };471 };
470472
471 // btrfs workaround; reopen tmp_directory473 // Apply btrfs workaround if needed. Reopen tmp_directory.
472 if (native_os == .linux and f.job_queue.work_around_btrfs_bug) {474 if (native_os == .linux and f.job_queue.work_around_btrfs_bug) {
473 // https://github.com/ziglang/zig/issues/17095475 // https://github.com/ziglang/zig/issues/17095
474 pkg_path.root_dir.handle.close();476 pkg_path.root_dir.handle.close();
...@@ -482,17 +484,18 @@ fn runResource(...@@ -482,17 +484,18 @@ fn runResource(
482 // considered to be a "naked" package.484 // considered to be a "naked" package.
483 try loadManifest(f, pkg_path);485 try loadManifest(f, pkg_path);
484486
485 // Apply the manifest's inclusion rules to the temporary directory by
486 // deleting excluded files. If any error occurred for files that were
487 // ultimately excluded, those errors should be ignored, such as failure to
488 // create symlinks that weren't supposed to be included anyway.
489
490 // Empty directories have already been omitted by `unpackResource`.
491
492 const filter: Filter = .{487 const filter: Filter = .{
493 .include_paths = if (f.manifest) |m| m.paths else .{},488 .include_paths = if (f.manifest) |m| m.paths else .{},
494 };489 };
495490
491 // TODO:
492 // If any error occurred for files that were ultimately excluded, those
493 // errors should be ignored, such as failure to create symlinks that
494 // weren't supposed to be included anyway.
495
496 // Apply the manifest's inclusion rules to the temporary directory by
497 // deleting excluded files.
498 // Empty directories have already been omitted by `unpackResource`.
496 // Compute the package hash based on the remaining files in the temporary499 // Compute the package hash based on the remaining files in the temporary
497 // directory.500 // directory.
498 f.actual_hash = try computeHash(f, pkg_path, filter);501 f.actual_hash = try computeHash(f, pkg_path, filter);
...@@ -522,7 +525,7 @@ fn runResource(...@@ -522,7 +525,7 @@ fn runResource(
522 ) });525 ) });
523 return error.FetchFailed;526 return error.FetchFailed;
524 };527 };
525 // Remove temporary directory root if not already renamed to cache.528 // Remove temporary directory root if not already renamed to global cache.
526 if (!std.mem.eql(u8, package_sub_path, tmp_dir_sub_path)) {529 if (!std.mem.eql(u8, package_sub_path, tmp_dir_sub_path)) {
527 cache_root.handle.deleteDir(tmp_dir_sub_path) catch {};530 cache_root.handle.deleteDir(tmp_dir_sub_path) catch {};
528 }531 }