mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
[bun.js] Bun.write for macOS
This commit is contained in:
@@ -303,7 +303,7 @@ pub const HTMLRewriter = struct {
|
||||
const is_pending = input.needsToReadFile();
|
||||
defer if (!is_pending) input.detach();
|
||||
|
||||
if (input.needsToReadFile()) {
|
||||
if (is_pending) {
|
||||
input.doReadFileInternal(*BufferOutputSink, sink, onFinishedLoadingWrap, global);
|
||||
} else if (sink.runOutputSink(input.sharedView(), false)) |error_value| {
|
||||
return error_value;
|
||||
@@ -321,8 +321,6 @@ pub const HTMLRewriter = struct {
|
||||
}
|
||||
|
||||
pub fn onFinishedLoading(sink: *BufferOutputSink, bytes: anyerror![]u8) void {
|
||||
var input = sink.input;
|
||||
defer input.detach();
|
||||
const data = bytes catch |err| {
|
||||
if (sink.response.body.value == .Locked and @ptrToInt(sink.response.body.value.Locked.task) == @ptrToInt(sink)) {
|
||||
sink.response.body.value = .{ .Empty = .{} };
|
||||
@@ -378,16 +376,10 @@ pub const HTMLRewriter = struct {
|
||||
this.response.body.value = .{
|
||||
.Blob = JSC.WebCore.Blob.init(bytes, this.bytes.allocator, this.global),
|
||||
};
|
||||
|
||||
if (prev_value.Locked.promise) |promise| {
|
||||
prev_value.Locked.promise = null;
|
||||
promise.asInternalPromise().?.resolve(this.global, JSC.JSValue.fromRef(
|
||||
Response.makeMaybePooled(
|
||||
this.global.ref(),
|
||||
this.response,
|
||||
),
|
||||
));
|
||||
}
|
||||
prev_value.resolve(
|
||||
&this.response.body.value,
|
||||
this.global,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn write(this: *BufferOutputSink, bytes: []const u8) void {
|
||||
|
||||
@@ -298,7 +298,7 @@ pub fn NewServer(comptime ssl_enabled: bool) type {
|
||||
}
|
||||
} else {
|
||||
var sbytes: std.os.off_t = adjusted_count;
|
||||
const signed_offset = @bitCast(i64, this.sendfile.offset);
|
||||
const signed_offset = @bitCast(i64, @as(u64, this.sendfile.offset));
|
||||
|
||||
// var sf_hdr_trailer: std.os.darwin.sf_hdtr = .{
|
||||
// .headers = &separator_iovec,
|
||||
@@ -320,9 +320,9 @@ pub fn NewServer(comptime ssl_enabled: bool) type {
|
||||
null,
|
||||
0,
|
||||
));
|
||||
|
||||
this.sendfile.offset += sbytes;
|
||||
this.sendfile.remain -= @intCast(JSC.WebCore.Blob.SizeType, sbytes);
|
||||
const wrote = @intCast(Blob.SizeType, sbytes);
|
||||
this.sendfile.offset += wrote;
|
||||
this.sendfile.remain -= wrote;
|
||||
if (errcode != .AGAIN or this.aborted or this.sendfile.remain == 0 or sbytes == 0) {
|
||||
if (errcode != .AGAIN and errcode != .SUCCESS) {
|
||||
Output.prettyErrorln("Error: {s}", .{@tagName(errcode)});
|
||||
|
||||
Reference in New Issue
Block a user