Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mordant-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
[bun_jsc]
"bare_bool_args:src/jsc/ZigStackFrame.rs" = 1
"defaulted_failure:src/jsc/ConsoleObject.rs" = 4
"reimplemented_helper:src/jsc/webcore_types.rs" = 1
"same_match_twice:src/jsc/VirtualMachine.rs" = 1

[bun_parsers]
Expand Down
11 changes: 3 additions & 8 deletions src/jsc/webcore_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,20 +415,15 @@ impl Blob {
}
}

/// `Blob.isBunFile()` — backed by a filesystem `Store::File`.
#[inline]
pub fn is_bun_file(&self) -> bool {
matches!(self.store.get().as_deref(), Some(s) if matches!(s.data, store::Data::File(_)))
}

/// `Blob.isS3()` — backed by an S3 `Store::S3`.
#[inline]
pub fn is_s3(&self) -> bool {
matches!(self.store.get().as_deref(), Some(s) if matches!(s.data, store::Data::S3(_)))
}

/// `Blob.needsToReadFile()` — true when bytes must be fetched off-disk
/// before any in-memory consumer can see them (i.e. `Store::File`).
/// `Blob.needsToReadFile()` — backed by a filesystem `Store::File` (a
/// `Bun.file()`), so the bytes must be fetched off-disk before any
/// in-memory consumer can see them.
#[inline]
pub fn needs_to_read_file(&self) -> bool {
matches!(self.store.get().as_deref(), Some(s) if matches!(s.data, store::Data::File(_)))
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/crypto/CryptoHasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ fn boring_engine(global: &JSGlobalObject) -> *mut boring_ssl::ENGINE {
.cast::<boring_ssl::ENGINE>()
}

/// Local helper replacing `input == .blob && input.blob.isBunFile()`.
/// The synchronous hashers only accept in-memory input, not a `Bun.file()`.
#[inline]
fn is_bun_file_blob(input: &BlobOrStringOrBuffer) -> bool {
match input {
BlobOrStringOrBuffer::Blob(b) => b.is_bun_file(),
BlobOrStringOrBuffer::Blob(b) => b.needs_to_read_file(),
_ => false,
}
}
Expand Down
10 changes: 3 additions & 7 deletions src/runtime/webcore/Blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,9 @@ pub use bun_jsc::generated::JSBlob as js;

// ──────────────────────────────────────────────────────────────────────────

// is_s3: defined once above (near is_bun_file); duplicate removed to fix E0034.

// is_all_ascii: canonical impl lives later in this file (pub). Duplicate
// private helper removed here to fix E0592.

// needs_to_read_file: defined once above; duplicate removed to fix E0034.

// ──────────────────────────────────────────────────────────────────────────
// BlobExt — `bun_runtime`-tier behaviour layered on the `bun_jsc` data type.
// Inherent methods (`new`/`init`/`shared_view`/`dupe`/`detach`/`deinit`/…)
Expand All @@ -153,9 +149,9 @@ pub use bun_jsc::generated::JSBlob as js;
#[allow(non_snake_case, clippy::too_many_arguments)]
pub trait BlobExt {
fn get_form_data_encoding(&self) -> Option<Box<bun_core::form_data::AsyncFormData>>;
// `has_content_type_from_user`/`content_type_or_mime_type`/`is_bun_file`/
// `is_s3`/`needs_to_read_file`/`get_file_name`: data-only predicates,
// hoisted to inherent `impl Blob` in `bun_jsc::webcore_types` (LAYERING).
// `has_content_type_from_user`/`content_type_or_mime_type`/`is_s3`/
// `needs_to_read_file`/`get_file_name`: data-only predicates, hoisted to
// inherent `impl Blob` in `bun_jsc::webcore_types` (LAYERING).
fn do_read_from_s3<F: read_file::ReadFileToJs>(
&self,
global: &JSGlobalObject,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/webcore/Response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ mod _jsc_host_fns {
match body {
BodyValue::Used | BodyValue::Empty | BodyValue::Null => JSValue::UNDEFINED,
BodyValue::Blob(blob) => {
if blob.is_bun_file() {
if blob.needs_to_read_file() {
return JSValue::UNDEFINED;
}
let result =
Expand Down
Loading