You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/08/06 03:24:54 UTC
[incubator-opendal] 02/03: Save work
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch change-list-api
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 73dc8a37378f7bc5d2044fbc5fd2767a38e0e518
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sun Aug 6 11:01:09 2023 +0800
Save work
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
bindings/nodejs/src/lib.rs | 9 ++++++++-
bindings/object_store/src/lib.rs | 3 ++-
bindings/python/src/asyncio.rs | 6 +++++-
core/src/layers/immutable_index.rs | 2 +-
core/src/types/operator/operator.rs | 2 +-
core/tests/behavior/list.rs | 7 +++++--
6 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/bindings/nodejs/src/lib.rs b/bindings/nodejs/src/lib.rs
index 5cc773dec..dbab75648 100644
--- a/bindings/nodejs/src/lib.rs
+++ b/bindings/nodejs/src/lib.rs
@@ -288,6 +288,7 @@ impl Operator {
/// An error will be returned if given path doesn't end with /.
///
/// ### Example
+ ///
/// ```javascript
/// const lister = await op.scan("/path/to/dir/");
/// while (true) {
@@ -303,7 +304,13 @@ impl Operator {
/// `````
#[napi]
pub async fn scan(&self, path: String) -> Result<Lister> {
- Ok(Lister(self.0.scan(&path).await.map_err(format_napi_error)?))
+ Ok(Lister(
+ self.0
+ .lister_with(&path)
+ .delimiter("")
+ .await
+ .map_err(format_napi_error)?,
+ ))
}
/// List dir in flat way synchronously.
diff --git a/bindings/object_store/src/lib.rs b/bindings/object_store/src/lib.rs
index 8733033e2..4e6784639 100644
--- a/bindings/object_store/src/lib.rs
+++ b/bindings/object_store/src/lib.rs
@@ -148,7 +148,8 @@ impl ObjectStore for OpendalStore {
let path = prefix.map_or("".into(), |x| format!("{}/", x));
let stream = self
.inner
- .scan(&path)
+ .lister_with(&path)
+ .delimiter("")
.await
.map_err(|err| format_object_store_error(err, &path))?;
diff --git a/bindings/python/src/asyncio.rs b/bindings/python/src/asyncio.rs
index 709b81f83..4b33015fa 100644
--- a/bindings/python/src/asyncio.rs
+++ b/bindings/python/src/asyncio.rs
@@ -149,7 +149,11 @@ impl AsyncOperator {
pub fn scan<'p>(&'p self, py: Python<'p>, path: String) -> PyResult<&'p PyAny> {
let this = self.0.clone();
future_into_py(py, async move {
- let lister = this.scan(&path).await.map_err(format_pyerr)?;
+ let lister = this
+ .lister_with(&path)
+ .delimiter("")
+ .await
+ .map_err(format_pyerr)?;
let pylister: PyObject = Python::with_gil(|py| AsyncLister::new(lister).into_py(py));
Ok(pylister)
})
diff --git a/core/src/layers/immutable_index.rs b/core/src/layers/immutable_index.rs
index 665d6f45d..cc2cf1907 100644
--- a/core/src/layers/immutable_index.rs
+++ b/core/src/layers/immutable_index.rs
@@ -452,7 +452,7 @@ mod tests {
.layer(iil)
.finish();
- let mut ds = op.scan("/").await?;
+ let mut ds = op.lister_with("/").delimiter("").await?;
let mut map = HashMap::new();
let mut set = HashSet::new();
diff --git a/core/src/types/operator/operator.rs b/core/src/types/operator/operator.rs
index 49bc5e851..df88a223f 100644
--- a/core/src/types/operator/operator.rs
+++ b/core/src/types/operator/operator.rs
@@ -1232,7 +1232,7 @@ impl Operator {
return self.delete(path).await;
}
- let obs = self.scan(path).await?;
+ let obs = self.lister_with(path).delimiter("").await?;
if self.info().can_batch() {
let mut obs = obs.try_chunks(self.limit());
diff --git a/core/tests/behavior/list.rs b/core/tests/behavior/list.rs
index 808748ce5..ed7067600 100644
--- a/core/tests/behavior/list.rs
+++ b/core/tests/behavior/list.rs
@@ -284,7 +284,7 @@ pub async fn test_list_with_start_after(op: Operator) -> Result<()> {
}
pub async fn test_scan_root(op: Operator) -> Result<()> {
- let w = op.scan("").await?;
+ let w = op.lister_with("").delimiter("").await?;
let actual = w
.try_collect::<Vec<_>>()
.await?
@@ -312,7 +312,10 @@ pub async fn test_scan(op: Operator) -> Result<()> {
}
}
- let w = op.scan(&format!("{parent}/x/")).await?;
+ let w = op
+ .lister_with(&format!("{parent}/x/"))
+ .delimiter("")
+ .await?;
let actual = w
.try_collect::<Vec<_>>()
.await?