diff options
author | 2021-10-04 20:42:17 -0700 | |
---|---|---|
committer | 2021-10-04 20:42:17 -0700 | |
commit | d2be50bf4d87de13a6010e93e3f100412d6290d2 (patch) | |
tree | 84ba4dcdb2bcfdd8db665021d8de3a3fe923f680 /src/bundler.zig | |
parent | f0f3d6d4eb7f7de92fe56aae235b62864c6e8a42 (diff) | |
parent | 21d918921a676fd14449e64a588123d7357f9ea9 (diff) | |
download | bun-d2be50bf4d87de13a6010e93e3f100412d6290d2.tar.gz bun-d2be50bf4d87de13a6010e93e3f100412d6290d2.tar.zst bun-d2be50bf4d87de13a6010e93e3f100412d6290d2.zip |
Merge branch 'main' of github.com:Jarred-Sumner/bun into mainbun-v0.0.32
Diffstat (limited to 'src/bundler.zig')
-rw-r--r-- | src/bundler.zig | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/bundler.zig b/src/bundler.zig index d1b530c82..2ca075760 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -700,15 +700,13 @@ pub const Bundler = struct { const tmpname = try bundler.fs.tmpname( ".bun", std.mem.span(&tmpname_buf), - std.hash.Wyhash.hash(0, std.mem.span(destination)), + std.hash.Wyhash.hash(@intCast(usize, std.time.milliTimestamp()) % std.math.maxInt(u32), std.mem.span(destination)), ); - var tmpfile = try tmpdir.createFileZ(tmpname, .{ .read = isDebug, .exclusive = true }); + var tmpfile = Fs.FileSystem.RealFS.Tmpfile{}; + try tmpfile.create(&bundler.fs.fs, tmpname); - errdefer { - tmpfile.close(); - tmpdir.deleteFile(std.mem.span(tmpname)) catch {}; - } + errdefer tmpfile.closeAndDelete(tmpname); var generator = try allocator.create(GenerateNodeModuleBundle); var queue = try BunQueue.init(allocator); @@ -722,7 +720,7 @@ pub const Bundler = struct { .estimated_input_lines_of_code = 0, // .resolve_queue = queue, .bundler = bundler, - .tmpfile = tmpfile, + .tmpfile = tmpfile.file(), .dynamic_import_file_size_store = U32Map.init(allocator), .dynamic_import_file_size_store_lock = Lock.init(), @@ -930,8 +928,7 @@ pub const Bundler = struct { // } if (this.log.errors > 0) { - tmpfile.close(); - tmpdir.deleteFile(std.mem.span(tmpname)) catch {}; + tmpfile.closeAndDelete(std.mem.span(tmpname)); // We stop here because if there are errors we don't know if the bundle is valid // This manifests as a crash when sorting through the module list because we may have added files to the bundle which were never actually finished being added. return null; @@ -1112,7 +1109,7 @@ pub const Bundler = struct { // chmod 777 0000010 | 0000100 | 0000001 | 0001000 | 0000040 | 0000004 | 0000002 | 0000400 | 0000200 | 0000020, ); - try std.os.renameatZ(tmpdir.fd, tmpname, top_dir.fd, destination); + try tmpfile.promote(tmpname, top_dir.fd, destination); // Print any errors at the end // try this.log.print(Output.errorWriter()); return javascript_bundle_container; |