Skip to content

Commit

Permalink
ci: set behavior test ci for aliyun drive (#4657)
Browse files Browse the repository at this point in the history
* ci: set behavior test ci for aliyun drive

Signed-off-by: suyanhanx <[email protected]>

* refactor(aliyun-drive): lister without get file detail

co-authored-by: yuchanns <[email protected]>
Signed-off-by: suyanhanx <[email protected]>

* bindings(py/nodejs/java): enable service aliyun_drive

Signed-off-by: suyanhanx <[email protected]>

---------

Signed-off-by: suyanhanx <[email protected]>
Co-authored-by: yuchanns <[email protected]>
Co-authored-by: Xuanwo <[email protected]>
  • Loading branch information
3 people authored Jun 18, 2024
1 parent c98e81f commit 8d39e5b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,8 @@ OPENDAL_ICLOUD_IS_CHINA_MAINLAND=true
# vercel blob
OPENDAL_VERCEL_BLOB_ROOT=/path/to/dir
OPENDAL_VERCEL_BLOB_TOKEN=<token>
# aliyun drive
OPENDAL_ALIYUN_DRIVE_ROOT=/path/to/dir
OPENDAL_ALIYUN_DRIVE_REFRESH_TOKEN=<refresh_token>
OPENDAL_ALIYUN_DRIVE_CLIENT_ID=<client_id>
OPENDAL_ALIYUN_DRIVE_CLIENT_SECRET=<client_secret>
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ runs:
OPENDAL_ALIYUN_DRIVE_REFRESH_TOKEN: op://services/aliyun_drive/refresh_token
OPENDAL_ALIYUN_DRIVE_CLIENT_ID: op://services/aliyun_drive/client_id
OPENDAL_ALIYUN_DRIVE_CLIENT_SECRET: op://services/aliyun_drive/client_secret
- name: Setup test threads
shell: bash
run: |
cat << EOF >> $GITHUB_ENV
RUST_TEST_THREADS=1
EOF
2 changes: 2 additions & 0 deletions bindings/java/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ default = [

services-all = [
"default",
"services-aliyun-drive",
"services-cacache",
"services-chainsafe",
"services-dashmap",
Expand Down Expand Up @@ -95,6 +96,7 @@ services-all = [
]

# Default services provided by opendal.
services-aliyun-drive = ["opendal/services-aliyun-drive"]
services-azblob = ["opendal/services-azblob"]
services-azdls = ["opendal/services-azdls"]
services-chainsafe = ["opendal/services-chainsafe"]
Expand Down
3 changes: 3 additions & 0 deletions bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ default = [

services-all = [
"default",
"services-aliyun-drive",
"services-alluxio",
"services-azfile",
"services-cacache",
"services-chainsafe",
Expand Down Expand Up @@ -92,6 +94,7 @@ services-all = [
]

# Default services provided by opendal.
services-aliyun-drive = ["opendal/services-aliyun-drive"]
services-azblob = ["opendal/services-azblob"]
services-azdls = ["opendal/services-azdls"]
services-chainsafe = ["opendal/services-chainsafe"]
Expand Down
2 changes: 2 additions & 0 deletions bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ default = [

services-all = [
"default",
"services-aliyun-drive",
"services-azfile",
"services-cacache",
"services-chainsafe",
Expand Down Expand Up @@ -92,6 +93,7 @@ services-all = [
]

# Default services provided by opendal.
services-aliyun-drive = ["opendal/services-aliyun-drive"]
services-azblob = ["opendal/services-azblob"]
services-azdls = ["opendal/services-azdls"]
services-chainsafe = ["opendal/services-chainsafe"]
Expand Down
19 changes: 7 additions & 12 deletions core/src/services/aliyun_drive/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use chrono::Utc;

use self::oio::Entry;
use super::core::AliyunDriveCore;
use super::core::AliyunDriveFile;
use super::core::AliyunDriveFileList;
use crate::raw::*;
use crate::EntryMode;
Expand Down Expand Up @@ -93,20 +92,16 @@ impl oio::PageList for AliyunDriveLister {
let n = result.items.len();

for item in result.items {
let res = self.core.get(&item.file_id).await?;
let file: AliyunDriveFile =
serde_json::from_reader(res.reader()).map_err(new_json_serialize_error)?;

let path = if parent.parent_path.starts_with('/') {
build_abs_path(&parent.parent_path, &file.name)
build_abs_path(&parent.parent_path, &item.name)
} else {
build_abs_path(&format!("/{}", &parent.parent_path), &file.name)
build_abs_path(&format!("/{}", &parent.parent_path), &item.name)
};

let (path, md) = if file.path_type == "folder" {
let (path, md) = if item.path_type == "folder" {
let path = format!("{}/", path);
let meta = Metadata::new(EntryMode::DIR).with_last_modified(
file.updated_at
item.updated_at
.parse::<chrono::DateTime<Utc>>()
.map_err(|e| {
Error::new(ErrorKind::Unexpected, "parse last modified time")
Expand All @@ -116,17 +111,17 @@ impl oio::PageList for AliyunDriveLister {
(path, meta)
} else {
let mut meta = Metadata::new(EntryMode::FILE).with_last_modified(
file.updated_at
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) = file.size {
if let Some(v) = item.size {
meta = meta.with_content_length(v);
}
if let Some(v) = file.content_type {
if let Some(v) = item.content_type {
meta = meta.with_content_type(v);
}
(path, meta)
Expand Down

0 comments on commit 8d39e5b

Please sign in to comment.