This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch fix-seafile
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 5487e26740c957d62dd1d395f1bdf66992399379
Author: Xuanwo <[email protected]>
AuthorDate: Wed Jan 31 20:33:38 2024 +0800

    Fix swift
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/services/swift/core.rs   |  4 ++++
 core/src/services/swift/lister.rs | 15 ++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/core/src/services/swift/core.rs b/core/src/services/swift/core.rs
index ca98a518ee..8753c964fb 100644
--- a/core/src/services/swift/core.rs
+++ b/core/src/services/swift/core.rs
@@ -73,6 +73,7 @@ impl SwiftCore {
         path: &str,
         delimiter: &str,
         limit: Option<usize>,
+        marker: &str,
     ) -> Result<Response<IncomingAsyncBody>> {
         let p = build_abs_path(&self.root, path);
 
@@ -90,6 +91,9 @@ impl SwiftCore {
         if let Some(limit) = limit {
             url += &format!("&limit={}", limit);
         }
+        if !marker.is_empty() {
+            url += &format!("&marker={}", marker);
+        }
 
         let mut req = Request::get(&url);
 
diff --git a/core/src/services/swift/lister.rs 
b/core/src/services/swift/lister.rs
index 2993269614..464f36a9c2 100644
--- a/core/src/services/swift/lister.rs
+++ b/core/src/services/swift/lister.rs
@@ -48,7 +48,7 @@ impl oio::PageList for SwiftLister {
     async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> {
         let response = self
             .core
-            .swift_list(&self.path, self.delimiter, self.limit)
+            .swift_list(&self.path, self.delimiter, self.limit, &ctx.token)
             .await?;
 
         let status_code = response.status();
@@ -58,12 +58,21 @@ impl oio::PageList for SwiftLister {
             return Err(error);
         }
 
-        ctx.done = true;
-
         let bytes = response.into_body().bytes().await?;
         let decoded_response: Vec<ListOpResponse> =
             
serde_json::from_slice(&bytes).map_err(new_json_deserialize_error)?;
 
+        // Update token and done based on resp.
+        if let Some(entry) = decoded_response.last() {
+            let path = match entry {
+                ListOpResponse::Subdir { subdir } => subdir,
+                ListOpResponse::FileInfo { name, .. } => name,
+            };
+            ctx.token = path.clone();
+        } else {
+            ctx.done = true;
+        }
+
         for status in decoded_response {
             let entry: oio::Entry = match status {
                 ListOpResponse::Subdir { subdir } => {

Reply via email to