Skip to content

Commit

Permalink
fix: MonoioFS execute blocking task without thread pool attached
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Nov 15, 2024
1 parent ea56dba commit b9ee792
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
4 changes: 3 additions & 1 deletion fusio-opendal/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ impl Fs for OpendalFs {
}

async fn link(&self, from: &Path, to: &Path) -> Result<(), Error> {
todo!()
Err(Error::Unsupported {
message: "opendal does not support link file".to_string(),
})
}
}
8 changes: 0 additions & 8 deletions fusio/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ pub enum Error {
Wasm {
message: String,
},
#[cfg(feature = "monoio")]
#[error("monoio JoinHandle was canceled")]
MonoIOJoinCancel,
#[error(transparent)]
Other(#[from] BoxedError),
}
Expand All @@ -37,8 +34,3 @@ pub(crate) fn wasm_err(js_val: js_sys::wasm_bindgen::JsValue) -> Error {
message: format!("{js_val:?}"),
}
}

#[cfg(feature = "monoio")]
pub(crate) fn monoio_join_err(_: monoio::blocking::JoinError) -> Error {
Error::MonoIOJoinCancel
}
10 changes: 2 additions & 8 deletions fusio/src/impls/disk/monoio/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ use std::{fs, fs::create_dir_all};

use async_stream::stream;
use futures_core::Stream;
use monoio::blocking::spawn_blocking;

use super::MonoioFile;
use crate::{
error::monoio_join_err,
fs::{FileMeta, FileSystemTag, Fs, OpenOptions},
path::{path_to_local, Path},
Error,
Expand Down Expand Up @@ -67,9 +65,7 @@ impl Fs for MonoIoFs {
let from = path_to_local(from)?;
let to = path_to_local(to)?;

spawn_blocking(move || fs::copy(&from, &to))
.await
.map_err(monoio_join_err)??;
let _ = monoio::spawn(async move { fs::copy(&from, &to) }).await?;

Ok(())
}
Expand All @@ -78,9 +74,7 @@ impl Fs for MonoIoFs {
let from = path_to_local(from)?;
let to = path_to_local(to)?;

spawn_blocking(move || fs::hard_link(&from, &to))
.await
.map_err(monoio_join_err)??;
let _ = monoio::spawn(async move { fs::hard_link(&from, &to) }).await?;

Ok(())
}
Expand Down

0 comments on commit b9ee792

Please sign in to comment.