Skip to content

Commit

Permalink
fix: return store directly from opendal_builder_to_sync_store
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Dec 10, 2024
1 parent db7c622 commit c288bda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
12 changes: 4 additions & 8 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ use zarrs::storage::{
storage_adapter::async_to_sync::AsyncToSyncStorageAdapter,
ReadableWritableListableStorageTraits,
};
use zarrs_opendal::AsyncOpendalStore;

use crate::{
runtime::{tokio_block_on, TokioBlockOn},
utils::PyErrExt,
};
use crate::{runtime::tokio_block_on, utils::PyErrExt};

mod filesystem;
mod http;
Expand Down Expand Up @@ -82,9 +78,9 @@ impl TryFrom<&StoreConfigType> for Arc<dyn ReadableWritableListableStorageTraits
}
}

type OpendalStoreSync = Arc<AsyncToSyncStorageAdapter<AsyncOpendalStore, TokioBlockOn>>;

fn opendal_builder_to_sync_store<B: Builder>(builder: B) -> PyResult<OpendalStoreSync> {
fn opendal_builder_to_sync_store<B: Builder>(
builder: B,
) -> PyResult<Arc<dyn ReadableWritableListableStorageTraits>> {
let operator = opendal::Operator::new(builder)
.map_py_err::<PyValueError>()?
.finish();
Expand Down
2 changes: 1 addition & 1 deletion src/store/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl TryInto<Arc<dyn ReadableWritableListableStorageTraits>> for &FilesystemStor
type Error = PyErr;

fn try_into(self) -> Result<Arc<dyn ReadableWritableListableStorageTraits>, Self::Error> {
let store: Arc<dyn ReadableWritableListableStorageTraits> =
let store =
Arc::new(FilesystemStore::new(self.root.clone()).map_py_err::<PyRuntimeError>()?);
Ok(store)
}
Expand Down
4 changes: 1 addition & 3 deletions src/store/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ impl TryInto<Arc<dyn ReadableWritableListableStorageTraits>> for &HttpStoreConfi

fn try_into(self) -> Result<Arc<dyn ReadableWritableListableStorageTraits>, Self::Error> {
let builder = opendal::services::Http::default().endpoint(&self.root);
let store: Arc<dyn ReadableWritableListableStorageTraits> =
opendal_builder_to_sync_store(builder)?;
Ok(store)
opendal_builder_to_sync_store(builder)
}
}

0 comments on commit c288bda

Please sign in to comment.