diff options
author | 2022-04-01 23:38:35 -0700 | |
---|---|---|
committer | 2022-04-01 23:38:35 -0700 | |
commit | 9bfd1801aab716718654ef346bd7ea362d208804 (patch) | |
tree | a6041c9f53d1dd23b9dae441e562dd59abf853bf | |
parent | b099e7232f8f69a663adb0e50eaa5c4300bbfbb4 (diff) | |
download | bun-9bfd1801aab716718654ef346bd7ea362d208804.tar.gz bun-9bfd1801aab716718654ef346bd7ea362d208804.tar.zst bun-9bfd1801aab716718654ef346bd7ea362d208804.zip |
[bun.js] slightly more careful write()
-rw-r--r-- | src/javascript/jsc/webcore/response.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/javascript/jsc/webcore/response.zig b/src/javascript/jsc/webcore/response.zig index eef272055..8d525f211 100644 --- a/src/javascript/jsc/webcore/response.zig +++ b/src/javascript/jsc/webcore/response.zig @@ -1817,7 +1817,7 @@ pub const Blob = struct { } const fd = this.getFd() catch return; - const needs_close = this.file_store.pathlike == .path; + const needs_close = this.file_store.pathlike == .path and fd != 0; const stat: std.os.Stat = switch (JSC.Node.Syscall.fstat(fd)) { .result => |result| result, .err => |err| { @@ -1963,6 +1963,7 @@ pub const Blob = struct { file_offset: u64, ) AsyncIO.WriteError!SizeType { var aio = &AsyncIO.global; + this.wrote = 0; aio.write( *WriteFile, this, @@ -2047,6 +2048,7 @@ pub const Blob = struct { if (needs_close) { this.doClose() catch {}; } + this.wrote = @truncate(SizeType, total_written); return; }; remain = remain[wrote_len..]; |