From b9ee7921b14c9f05c66699209142e4270255a748 Mon Sep 17 00:00:00 2001 From: kkould <2435992353@qq.com> Date: Fri, 15 Nov 2024 03:35:24 +0000 Subject: [PATCH] fix: MonoioFS execute blocking task without thread pool attached --- fusio-opendal/src/fs.rs | 4 +++- fusio/src/error.rs | 8 -------- fusio/src/impls/disk/monoio/fs.rs | 10 ++-------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/fusio-opendal/src/fs.rs b/fusio-opendal/src/fs.rs index 0e04361..f579036 100644 --- a/fusio-opendal/src/fs.rs +++ b/fusio-opendal/src/fs.rs @@ -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(), + }) } } diff --git a/fusio/src/error.rs b/fusio/src/error.rs index 973f4b2..550709a 100644 --- a/fusio/src/error.rs +++ b/fusio/src/error.rs @@ -22,9 +22,6 @@ pub enum Error { Wasm { message: String, }, - #[cfg(feature = "monoio")] - #[error("monoio JoinHandle was canceled")] - MonoIOJoinCancel, #[error(transparent)] Other(#[from] BoxedError), } @@ -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 -} diff --git a/fusio/src/impls/disk/monoio/fs.rs b/fusio/src/impls/disk/monoio/fs.rs index 3bfacdd..58de060 100644 --- a/fusio/src/impls/disk/monoio/fs.rs +++ b/fusio/src/impls/disk/monoio/fs.rs @@ -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, @@ -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(()) } @@ -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(()) }