@@ -354,53 +354,55 @@ fn runResource(
354
354
const rand_int = std .crypto .random .int (u64 );
355
355
const tmp_dir_sub_path = "tmp" ++ s ++ Manifest .hex64 (rand_int );
356
356
357
- const tmp_directory_path = try cache_root .join (arena , &.{tmp_dir_sub_path });
358
- var tmp_directory : Cache.Directory = .{
359
- .path = tmp_directory_path ,
360
- .handle = handle : {
361
- const dir = cache_root .handle .makeOpenPathIterable (tmp_dir_sub_path , .{}) catch | err | {
362
- try eb .addRootErrorMessage (.{
363
- .msg = try eb .printString ("unable to create temporary directory '{s}': {s}" , .{
364
- tmp_directory_path , @errorName (err ),
365
- }),
366
- });
367
- return error .FetchFailed ;
368
- };
369
- break :handle dir .dir ;
370
- },
371
- };
372
- defer tmp_directory .handle .close ();
357
+ {
358
+ const tmp_directory_path = try cache_root .join (arena , &.{tmp_dir_sub_path });
359
+ var tmp_directory : Cache.Directory = .{
360
+ .path = tmp_directory_path ,
361
+ .handle = handle : {
362
+ const dir = cache_root .handle .makeOpenPathIterable (tmp_dir_sub_path , .{}) catch | err | {
363
+ try eb .addRootErrorMessage (.{
364
+ .msg = try eb .printString ("unable to create temporary directory '{s}': {s}" , .{
365
+ tmp_directory_path , @errorName (err ),
366
+ }),
367
+ });
368
+ return error .FetchFailed ;
369
+ };
370
+ break :handle dir .dir ;
371
+ },
372
+ };
373
+ defer tmp_directory .handle .close ();
373
374
374
- try unpackResource (f , resource , uri_path , tmp_directory );
375
+ try unpackResource (f , resource , uri_path , tmp_directory );
375
376
376
- // Load, parse, and validate the unpacked build.zig.zon file. It is allowed
377
- // for the file to be missing, in which case this fetched package is
378
- // considered to be a "naked" package.
379
- try loadManifest (f , .{ .root_dir = tmp_directory });
377
+ // Load, parse, and validate the unpacked build.zig.zon file. It is allowed
378
+ // for the file to be missing, in which case this fetched package is
379
+ // considered to be a "naked" package.
380
+ try loadManifest (f , .{ .root_dir = tmp_directory });
380
381
381
- // Apply the manifest's inclusion rules to the temporary directory by
382
- // deleting excluded files. If any error occurred for files that were
383
- // ultimately excluded, those errors should be ignored, such as failure to
384
- // create symlinks that weren't supposed to be included anyway.
382
+ // Apply the manifest's inclusion rules to the temporary directory by
383
+ // deleting excluded files. If any error occurred for files that were
384
+ // ultimately excluded, those errors should be ignored, such as failure to
385
+ // create symlinks that weren't supposed to be included anyway.
385
386
386
- // Empty directories have already been omitted by `unpackResource`.
387
+ // Empty directories have already been omitted by `unpackResource`.
387
388
388
- const filter : Filter = .{
389
- .include_paths = if (f .manifest ) | m | m .paths else .{},
390
- };
389
+ const filter : Filter = .{
390
+ .include_paths = if (f .manifest ) | m | m .paths else .{},
391
+ };
391
392
392
- // Compute the package hash based on the remaining files in the temporary
393
- // directory.
393
+ // Compute the package hash based on the remaining files in the temporary
394
+ // directory.
394
395
395
- if (builtin .os .tag == .linux and f .job_queue .work_around_btrfs_bug ) {
396
- // https://github.com/ziglang/zig/issues/17095
397
- tmp_directory .handle .close ();
398
- const iterable_dir = cache_root .handle .makeOpenPathIterable (tmp_dir_sub_path , .{}) catch
399
- @panic ("btrfs workaround failed" );
400
- tmp_directory .handle = iterable_dir .dir ;
401
- }
396
+ if (builtin .os .tag == .linux and f .job_queue .work_around_btrfs_bug ) {
397
+ // https://github.com/ziglang/zig/issues/17095
398
+ tmp_directory .handle .close ();
399
+ const iterable_dir = cache_root .handle .makeOpenPathIterable (tmp_dir_sub_path , .{}) catch
400
+ @panic ("btrfs workaround failed" );
401
+ tmp_directory .handle = iterable_dir .dir ;
402
+ }
402
403
403
- f .actual_hash = try computeHash (f , tmp_directory , filter );
404
+ f .actual_hash = try computeHash (f , tmp_directory , filter );
405
+ }
404
406
405
407
// Rename the temporary directory into the global zig package cache
406
408
// directory. If the hash already exists, delete the temporary directory
0 commit comments