diff options
author | Igor Zinkovsky <igor@deno.com> | 2023-04-28 12:16:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 12:16:17 -0700 |
commit | 10ae5ee26557107b22524b1a84ebb56ed7d23fb4 (patch) | |
tree | fb5388dff1531a6ac692bb52387697adc39d14b3 /core/resources.rs | |
parent | 6369098ad74a263e461478f94782bc469de15468 (diff) |
fix(ext/io) several sync fs fixes (#18886)
2 fixes related to sync fs:
* update the 2 sync methods on `Resource` trait to take `Rc<Self>`
(consistent with other methods)
* fix a bug in `StdFileResource::with_inner_and_metadata`, which
currently can trigger a panic if a sync method is called on a file with
a pending async operation. This could happen in the code path where
`File::try_clone`
[fails](https://github.com/denoland/deno/blob/39ece1fe0ddacc2cbf182403c9e7085bc01df5a6/ext/io/lib.rs#L485-L489).
Diffstat (limited to 'core/resources.rs')
-rw-r--r-- | core/resources.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/resources.rs b/core/resources.rs index 6ca86e10b..84e6847fc 100644 --- a/core/resources.rs +++ b/core/resources.rs @@ -155,13 +155,13 @@ pub trait Resource: Any + 'static { } /// The same as [`read_byob()`][Resource::read_byob], but synchronous. - fn read_byob_sync(&self, data: &mut [u8]) -> Result<usize, Error> { + fn read_byob_sync(self: Rc<Self>, data: &mut [u8]) -> Result<usize, Error> { _ = data; Err(not_supported()) } /// The same as [`write()`][Resource::write], but synchronous. - fn write_sync(&self, data: &[u8]) -> Result<usize, Error> { + fn write_sync(self: Rc<Self>, data: &[u8]) -> Result<usize, Error> { _ = data; Err(not_supported()) } |