Skip to content

Commit

Permalink
Fix aliyun drive
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo committed Aug 26, 2024
1 parent 38d67ed commit d51df2e
Showing 1 changed file with 19 additions and 37 deletions.
56 changes: 19 additions & 37 deletions core/src/services/aliyun_drive/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,53 +100,35 @@ impl oio::PageList for AliyunDriveLister {
let result: AliyunDriveFileList =
serde_json::from_reader(res.reader()).map_err(new_json_serialize_error)?;

let n = result.items.len();

for item in result.items {
let path = build_abs_path(&parent.path, &item.name);

let (path, md) = if item.path_type == "folder" {
let path = format!("{}/", path);
let meta = Metadata::new(EntryMode::DIR).with_last_modified(
item.updated_at
.parse::<chrono::DateTime<Utc>>()
.map_err(|e| {
Error::new(ErrorKind::Unexpected, "parse last modified time")
.set_source(e)
})?,
);
(path, meta)
let (path, mut md) = if item.path_type == "folder" {
let path = format!("{}{}/", &parent.path.trim_start_matches('/'), &item.name);
(path, Metadata::new(EntryMode::DIR))
} else {
let mut meta = Metadata::new(EntryMode::FILE).with_last_modified(
item.updated_at
.parse::<chrono::DateTime<Utc>>()
.map_err(|e| {
Error::new(ErrorKind::Unexpected, "parse last modified time")
.set_source(e)
})?,
);
if let Some(v) = item.size {
meta = meta.with_content_length(v);
}
if let Some(v) = item.content_type {
meta = meta.with_content_type(v);
}
(path, meta)
let path = format!("{}{}", &parent.path.trim_start_matches('/'), &item.name);
(path, Metadata::new(EntryMode::FILE))
};

md = md.with_last_modified(item.updated_at.parse::<chrono::DateTime<Utc>>().map_err(
|e| Error::new(ErrorKind::Unexpected, "parse last modified time").set_source(e),
)?);
if let Some(v) = item.size {
md = md.with_content_length(v);
}
if let Some(v) = item.content_type {
md = md.with_content_type(v);
}

ctx.entries.push_back(Entry::new(&path, md));
}

if self.limit.is_some_and(|x| x < n) || result.next_marker.is_none() {
let next_marker = result.next_marker.unwrap_or_default();
if next_marker.is_empty() {
ctx.done = true;
} else {
ctx.token = next_marker;
}

if let Some(marker) = result.next_marker {
if marker.is_empty() {
ctx.done = true;
}
ctx.token = marker;
}
Ok(())
}
}

0 comments on commit d51df2e

Please sign in to comment.