Skip to content

Commit 2de0863

Browse files
committed
use local cache dir for dependencies-listing package
1 parent 741445c commit 2de0863

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Package.zig

+5-5
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ pub fn fetchAndAddDependencies(
249249

250250
pub fn createFilePkg(
251251
gpa: Allocator,
252-
global_cache_directory: Compilation.Directory,
252+
cache_directory: Compilation.Directory,
253253
basename: []const u8,
254254
contents: []const u8,
255255
) !*Package {
256256
const rand_int = std.crypto.random.int(u64);
257257
const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ hex64(rand_int);
258258
{
259-
var tmp_dir = try global_cache_directory.handle.makeOpenPath(tmp_dir_sub_path, .{});
259+
var tmp_dir = try cache_directory.handle.makeOpenPath(tmp_dir_sub_path, .{});
260260
defer tmp_dir.close();
261261
try tmp_dir.writeFile(basename, contents);
262262
}
@@ -267,9 +267,9 @@ pub fn createFilePkg(
267267
const hex_digest = hh.final();
268268

269269
const o_dir_sub_path = "o" ++ fs.path.sep_str ++ hex_digest;
270-
try renameTmpIntoCache(global_cache_directory.handle, tmp_dir_sub_path, o_dir_sub_path);
270+
try renameTmpIntoCache(cache_directory.handle, tmp_dir_sub_path, o_dir_sub_path);
271271

272-
return createWithDir(gpa, global_cache_directory, o_dir_sub_path, basename);
272+
return createWithDir(gpa, cache_directory, o_dir_sub_path, basename);
273273
}
274274

275275
fn fetchAndUnpack(
@@ -558,7 +558,7 @@ fn renameTmpIntoCache(
558558
tmp_dir_sub_path: []const u8,
559559
dest_dir_sub_path: []const u8,
560560
) !void {
561-
assert(dest_dir_sub_path[1] == '/');
561+
assert(dest_dir_sub_path[1] == fs.path.sep);
562562
var handled_missing_dir = false;
563563
while (true) {
564564
cache_dir.rename(tmp_dir_sub_path, dest_dir_sub_path) catch |err| switch (err) {

src/main.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -4116,7 +4116,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
41164116

41174117
const deps_pkg = try Package.createFilePkg(
41184118
gpa,
4119-
global_cache_directory,
4119+
local_cache_directory,
41204120
"dependencies.zig",
41214121
dependencies_source.items,
41224122
);

0 commit comments

Comments
 (0)