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(
461461 };
462462 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.
464466 const pkg_dir = try unpackResource(f, resource, uri_path, tmp_directory);
465467
466 var pkg_path: Cache.Path = if (pkg_dir) |pkg_dir_name|
467 .{ .root_dir = tmp_directory, .sub_path = pkg_dir_name }
468 else
469 .{ .root_dir = tmp_directory };
468 var pkg_path: Cache.Path = .{
469 .root_dir = tmp_directory,
470 .sub_path = if (pkg_dir) |pkg_dir_name| pkg_dir_name else "",
471 };
470472
471 // btrfs workaround; reopen tmp_directory
473 // Apply btrfs workaround if needed. Reopen tmp_directory.
472474 if (native_os == .linux and f.job_queue.work_around_btrfs_bug) {
473475 // https://github.com/ziglang/zig/issues/17095
474476 pkg_path.root_dir.handle.close();
......@@ -482,17 +484,18 @@ fn runResource(
482484 // considered to be a "naked" package.
483485 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
492487 const filter: Filter = .{
493488 .include_paths = if (f.manifest) |m| m.paths else .{},
494489 };
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`.
496499 // Compute the package hash based on the remaining files in the temporary
497500 // directory.
498501 f.actual_hash = try computeHash(f, pkg_path, filter);
......@@ -522,7 +525,7 @@ fn runResource(
522525 ) });
523526 return error.FetchFailed;
524527 };
525 // Remove temporary directory root if not already renamed to cache.
528 // Remove temporary directory root if not already renamed to global cache.
526529 if (!std.mem.eql(u8, package_sub_path, tmp_dir_sub_path)) {
527530 cache_root.handle.deleteDir(tmp_dir_sub_path) catch {};
528531 }