authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-13 17:05:21-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-14 09:34:15+01:00
logf996d28666e7d562b6a18e9f80fe31a3463456d0
tree71a93aa03b23429488dfa7396bcb914ed3cd68df
parent017228de89ef2ea4ed229c4eea62317826a909b6

fetch: use tmp dir inside zig-pkg/

Using the tmp dir of the local .zig-cache/ could result in error.CrossDevice if the user chose a non-default local cache path. closes #31148

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

src/Package/Fetch.zig+2-4
...@@ -684,15 +684,13 @@ fn runResource(...@@ -684,15 +684,13 @@ fn runResource(
684684
685 const arena = f.arena.allocator();685 const arena = f.arena.allocator();
686 const eb = &f.error_bundle;686 const eb = &f.error_bundle;
687 const s = fs.path.sep_str;
688 const local_cache_root = job_queue.local_cache;
689 const rand_int = r: {687 const rand_int = r: {
690 var x: u64 = undefined;688 var x: u64 = undefined;
691 io.random(@ptrCast(&x));689 io.random(@ptrCast(&x));
692 break :r x;690 break :r x;
693 };691 };
694 const tmp_dir_sub_path = "tmp" ++ s ++ std.fmt.hex(rand_int);692 const tmp_dir_sub_path = ".tmp-" ++ std.fmt.hex(rand_int);
695 const tmp_directory_path = try local_cache_root.join(arena, tmp_dir_sub_path);693 const tmp_directory_path = try job_queue.root_pkg_path.join(arena, tmp_dir_sub_path);
696694
697 const package_sub_path = blk: {695 const package_sub_path = blk: {
698 var tmp_directory: Cache.Directory = .{696 var tmp_directory: Cache.Directory = .{