Skip to content

Commit

Permalink
feat: Implement list with metakey for blocking (#2861)
Browse files Browse the repository at this point in the history
* Save work

Signed-off-by: Xuanwo <github@xuanwo.io>

* Implement list for blocking operator

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix docs

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix test

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo committed Aug 14, 2023
1 parent bb51cbe commit f7486c4
Show file tree
Hide file tree
Showing 7 changed files with 387 additions and 74 deletions.
2 changes: 1 addition & 1 deletion bindings/c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ pub unsafe extern "C" fn opendal_operator_blocking_list(

let op = (*ptr).as_ref();
let path = unsafe { std::ffi::CStr::from_ptr(path).to_str().unwrap() };
match op.list(path) {
match op.lister(path) {
Ok(lister) => opendal_result_list {
lister: Box::into_raw(Box::new(opendal_blocking_lister::new(lister))),
code: opendal_code::OPENDAL_OK,
Expand Down
4 changes: 2 additions & 2 deletions bindings/haskell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ pub unsafe extern "C" fn blocking_list(
}
};

let res = match op.list(path_str) {
let res = match op.lister(path_str) {
Ok(lister) => FFIResult::ok(Box::into_raw(Box::new(lister))),
Err(e) => FFIResult::err_with_source("Failed to list", e),
};
Expand Down Expand Up @@ -540,7 +540,7 @@ pub unsafe extern "C" fn blocking_scan(
}
};

let res = match op.scan(path_str) {
let res = match op.lister_with(path_str).delimiter("").call() {
Ok(lister) => FFIResult::ok(Box::into_raw(Box::new(lister))),
Err(e) => FFIResult::err_with_source("Failed to scan", e),
};
Expand Down
14 changes: 12 additions & 2 deletions bindings/nodejs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ impl Operator {
#[napi]
pub fn scan_sync(&self, path: String) -> Result<BlockingLister> {
Ok(BlockingLister(
self.0.blocking().scan(&path).map_err(format_napi_error)?,
self.0
.blocking()
.lister_with(&path)
.delimiter("")
.call()
.map_err(format_napi_error)?,
))
}

Expand Down Expand Up @@ -443,7 +448,12 @@ impl Operator {
#[napi]
pub fn list_sync(&self, path: String) -> Result<BlockingLister> {
Ok(BlockingLister(
self.0.blocking().scan(&path).map_err(format_napi_error)?,
self.0
.blocking()
.lister_with(&path)
.delimiter("")
.call()
.map_err(format_napi_error)?,
))
}

Expand Down
10 changes: 8 additions & 2 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,18 @@ impl Operator {

/// List current dir path.
pub fn list(&self, path: &str) -> PyResult<BlockingLister> {
Ok(BlockingLister(self.0.list(path).map_err(format_pyerr)?))
Ok(BlockingLister(self.0.lister(path).map_err(format_pyerr)?))
}

/// List dir in flat way.
pub fn scan(&self, path: &str) -> PyResult<BlockingLister> {
Ok(BlockingLister(self.0.scan(path).map_err(format_pyerr)?))
Ok(BlockingLister(
self.0
.lister_with(path)
.delimiter("")
.call()
.map_err(format_pyerr)?,
))
}

fn __repr__(&self) -> String {
Expand Down

0 comments on commit f7486c4

Please sign in to comment.