This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch xuanwo/move-aliyun-drive in repository https://gitbox.apache.org/repos/asf/opendal.git
commit f84e0c8e3c6a3b4dcd7dde7ea828efc458e9c135 Author: Xuanwo <[email protected]> AuthorDate: Mon Dec 8 18:06:16 2025 +0800 refactor: Split service aliyun drive to new crate Signed-off-by: Xuanwo <[email protected]> --- core/Cargo.lock | 16 +++++++++ core/Cargo.toml | 4 ++- core/core/Cargo.toml | 1 - core/core/src/services/mod.rs | 5 --- core/services/aliyun-drive/Cargo.toml | 40 ++++++++++++++++++++++ .../aliyun-drive/src}/backend.rs | 4 +-- .../aliyun-drive/src}/config.rs | 24 ++++++------- .../aliyun-drive/src}/core.rs | 4 +-- .../aliyun-drive/src}/deleter.rs | 4 +-- .../aliyun-drive/src}/docs.md | 2 +- .../aliyun-drive/src}/error.rs | 2 +- .../mod.rs => services/aliyun-drive/src/lib.rs} | 4 +-- .../aliyun-drive/src}/lister.rs | 12 +++---- .../aliyun-drive/src}/writer.rs | 9 +++-- core/src/lib.rs | 2 ++ 15 files changed, 93 insertions(+), 40 deletions(-) diff --git a/core/Cargo.lock b/core/Cargo.lock index 6f80b77a0..6990a36ae 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -5477,6 +5477,7 @@ dependencies = [ "opendal-core", "opendal-layer-async-backtrace", "opendal-layer-await-tree", + "opendal-service-aliyun-drive", "opendal-service-azblob", "opendal-service-azdls", "opendal-service-azfile", @@ -5666,6 +5667,21 @@ dependencies = [ "opendal-core", ] +[[package]] +name = "opendal-service-aliyun-drive" +version = "0.55.0" +dependencies = [ + "bytes", + "ctor", + "http 1.4.0", + "log", + "mea", + "opendal-core", + "pretty_assertions", + "serde", + "serde_json", +] + [[package]] name = "opendal-service-azblob" version = "0.55.0" diff --git a/core/Cargo.toml b/core/Cargo.toml index 7c5ecbfc2..191360ba3 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -24,6 +24,7 @@ members = [ "fuzz", "edge/*", "benches/vs_*", + "services/aliyun-drive", "services/*", "layers/*", "layers/await-tree", @@ -77,7 +78,7 @@ layers-prometheus-client = ["opendal-core/layers-prometheus-client"] layers-throttle = ["opendal-core/layers-throttle"] layers-tracing = ["opendal-core/layers-tracing"] reqwest-rustls-tls = ["opendal-core/reqwest-rustls-tls"] -services-aliyun-drive = ["opendal-core/services-aliyun-drive"] +services-aliyun-drive = ["dep:opendal-service-aliyun-drive"] services-alluxio = ["opendal-core/services-alluxio"] services-azblob = ["dep:opendal-service-azblob"] services-azdls = ["dep:opendal-service-azdls"] @@ -170,6 +171,7 @@ opendal-service-azblob = { path = "services/azblob", version = "0.55.0", optiona opendal-service-azdls = { path = "services/azdls", version = "0.55.0", optional = true, default-features = false } opendal-service-azfile = { path = "services/azfile", version = "0.55.0", optional = true, default-features = false } opendal-service-ghac = { path = "services/ghac", version = "0.55.0", optional = true, default-features = false } +opendal-service-aliyun-drive = { path = "services/aliyun-drive", version = "0.55.0", optional = true, default-features = false } [dev-dependencies] anyhow = { version = "1.0.100", features = ["std"] } diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml index a8c3d4924..19e1a33b1 100644 --- a/core/core/Cargo.toml +++ b/core/core/Cargo.toml @@ -95,7 +95,6 @@ layers-throttle = ["dep:governor"] # Enable dtrace support. layers-dtrace = ["dep:probe"] -services-aliyun-drive = [] services-alluxio = [] services-b2 = [] services-cacache = ["dep:cacache"] diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs index 549ff6e79..d0dfb83a4 100644 --- a/core/core/src/services/mod.rs +++ b/core/core/src/services/mod.rs @@ -19,11 +19,6 @@ //! //! More ongoing services support is tracked at [opendal#5](https://github.com/apache/opendal/issues/5). Please feel free to submit issues if there are services not covered. -#[cfg(feature = "services-aliyun-drive")] -mod aliyun_drive; -#[cfg(feature = "services-aliyun-drive")] -pub use aliyun_drive::*; - #[cfg(feature = "services-alluxio")] mod alluxio; #[cfg(feature = "services-alluxio")] diff --git a/core/services/aliyun-drive/Cargo.toml b/core/services/aliyun-drive/Cargo.toml new file mode 100644 index 000000000..89ad86990 --- /dev/null +++ b/core/services/aliyun-drive/Cargo.toml @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[package] +name = "opendal-service-aliyun-drive" +version = "0.55.0" +edition = "2024" +license = "Apache-2.0" +repository = "https://github.com/apache/opendal" +description = "Apache OpenDAL Aliyun Drive service implementation" + +[package.metadata.docs.rs] +all-features = true + +[dependencies] +opendal-core = { path = "../../core", version = "0.55.0", default-features = false } +bytes = "1.6" +ctor = "0.6" +http = "1.1" +log = "0.4" +mea = { version = "0.5.1" } +serde = { version = "1", features = ["derive"] } +serde_json = "1" + +[dev-dependencies] +pretty_assertions = "1" diff --git a/core/core/src/services/aliyun_drive/backend.rs b/core/services/aliyun-drive/src/backend.rs similarity index 99% rename from core/core/src/services/aliyun_drive/backend.rs rename to core/services/aliyun-drive/src/backend.rs index f46a37d6c..de752ac99 100644 --- a/core/core/src/services/aliyun_drive/backend.rs +++ b/core/services/aliyun-drive/src/backend.rs @@ -32,8 +32,8 @@ use super::error::parse_error; use super::lister::AliyunDriveLister; use super::lister::AliyunDriveParent; use super::writer::AliyunDriveWriter; -use crate::raw::*; -use crate::*; +use opendal_core::raw::*; +use opendal_core::*; #[doc = include_str!("docs.md")] #[derive(Default)] diff --git a/core/core/src/services/aliyun_drive/config.rs b/core/services/aliyun-drive/src/config.rs similarity index 87% rename from core/core/src/services/aliyun_drive/config.rs rename to core/services/aliyun-drive/src/config.rs index 85c06bdaa..899f7c83c 100644 --- a/core/core/src/services/aliyun_drive/config.rs +++ b/core/services/aliyun-drive/src/config.rs @@ -70,22 +70,22 @@ impl Debug for AliyunDriveConfig { } } -impl crate::Configurator for AliyunDriveConfig { +impl opendal_core::Configurator for AliyunDriveConfig { type Builder = AliyunDriveBuilder; - fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> { + fn from_uri(uri: &opendal_core::OperatorUri) -> opendal_core::Result<Self> { let mut map = uri.options().clone(); - if let Some(drive_type) = uri.name() { - if !drive_type.is_empty() { - map.insert("drive_type".to_string(), drive_type.to_string()); - } + if let Some(drive_type) = uri.name() + && !drive_type.is_empty() + { + map.insert("drive_type".to_string(), drive_type.to_string()); } - if let Some(root) = uri.root() { - if !root.is_empty() { - map.insert("root".to_string(), root.to_string()); - } + if let Some(root) = uri.root() + && !root.is_empty() + { + map.insert("root".to_string(), root.to_string()); } Self::from_iter(map) @@ -100,8 +100,8 @@ impl crate::Configurator for AliyunDriveConfig { #[cfg(test)] mod tests { use super::*; - use crate::Configurator; - use crate::types::OperatorUri; + use opendal_core::Configurator; + use opendal_core::OperatorUri; #[test] fn from_uri_sets_drive_type_and_root() { diff --git a/core/core/src/services/aliyun_drive/core.rs b/core/services/aliyun-drive/src/core.rs similarity index 99% rename from core/core/src/services/aliyun_drive/core.rs rename to core/services/aliyun-drive/src/core.rs index 05cee528b..448ed8381 100644 --- a/core/core/src/services/aliyun_drive/core.rs +++ b/core/services/aliyun-drive/src/core.rs @@ -29,8 +29,8 @@ use serde::Deserialize; use serde::Serialize; use super::error::parse_error; -use crate::raw::*; -use crate::*; +use opendal_core::raw::*; +use opendal_core::*; /// Available Aliyun Drive Type. #[derive(Debug, Deserialize, Default, Clone)] diff --git a/core/core/src/services/aliyun_drive/deleter.rs b/core/services/aliyun-drive/src/deleter.rs similarity index 97% rename from core/core/src/services/aliyun_drive/deleter.rs rename to core/services/aliyun-drive/src/deleter.rs index 50936bab2..74a83bb2f 100644 --- a/core/core/src/services/aliyun_drive/deleter.rs +++ b/core/services/aliyun-drive/src/deleter.rs @@ -21,8 +21,8 @@ use bytes::Buf; use super::core::AliyunDriveCore; use super::core::AliyunDriveFile; -use crate::raw::*; -use crate::*; +use opendal_core::raw::*; +use opendal_core::*; pub struct AliyunDriveDeleter { core: Arc<AliyunDriveCore>, diff --git a/core/core/src/services/aliyun_drive/docs.md b/core/services/aliyun-drive/src/docs.md similarity index 96% rename from core/core/src/services/aliyun_drive/docs.md rename to core/services/aliyun-drive/src/docs.md index f0eecd3e6..9c21bb7ee 100644 --- a/core/core/src/services/aliyun_drive/docs.md +++ b/core/services/aliyun-drive/src/docs.md @@ -31,7 +31,7 @@ Refer to [`AliyunDriveBuilder`]`s public API docs for more information. use std::sync::Arc; use anyhow::Result; -use opendal_core::services::AliyunDrive; +use opendal_service_aliyun_drive::AliyunDrive; use opendal_core::Operator; #[tokio::main] diff --git a/core/core/src/services/aliyun_drive/error.rs b/core/services/aliyun-drive/src/error.rs similarity index 99% rename from core/core/src/services/aliyun_drive/error.rs rename to core/services/aliyun-drive/src/error.rs index fc90cfcd8..0bf7484d8 100644 --- a/core/core/src/services/aliyun_drive/error.rs +++ b/core/services/aliyun-drive/src/error.rs @@ -19,7 +19,7 @@ use bytes::Buf; use http::Response; use serde::Deserialize; -use crate::*; +use opendal_core::*; #[derive(Default, Debug, Deserialize)] struct AliyunDriveError { diff --git a/core/core/src/services/aliyun_drive/mod.rs b/core/services/aliyun-drive/src/lib.rs similarity index 93% rename from core/core/src/services/aliyun_drive/mod.rs rename to core/services/aliyun-drive/src/lib.rs index e7c54d0a2..a70d37719 100644 --- a/core/core/src/services/aliyun_drive/mod.rs +++ b/core/services/aliyun-drive/src/lib.rs @@ -18,7 +18,7 @@ /// Default scheme for aliyun-drive service. pub const ALIYUN_DRIVE_SCHEME: &str = "aliyun-drive"; -use crate::types::DEFAULT_OPERATOR_REGISTRY; +use opendal_core::DEFAULT_OPERATOR_REGISTRY; mod backend; mod config; @@ -32,6 +32,6 @@ pub use backend::AliyunDriveBuilder as AliyunDrive; pub use config::AliyunDriveConfig; #[ctor::ctor] -fn register_aliyundrive_service() { +fn register_aliyun_drive_service() { DEFAULT_OPERATOR_REGISTRY.register::<AliyunDrive>(ALIYUN_DRIVE_SCHEME); } diff --git a/core/core/src/services/aliyun_drive/lister.rs b/core/services/aliyun-drive/src/lister.rs similarity index 95% rename from core/core/src/services/aliyun_drive/lister.rs rename to core/services/aliyun-drive/src/lister.rs index 8fa9e795a..de437e5e1 100644 --- a/core/core/src/services/aliyun_drive/lister.rs +++ b/core/services/aliyun-drive/src/lister.rs @@ -20,13 +20,13 @@ use std::sync::Arc; use self::oio::Entry; use super::core::AliyunDriveCore; use super::core::AliyunDriveFileList; -use crate::EntryMode; -use crate::Error; -use crate::ErrorKind; -use crate::Metadata; -use crate::Result; -use crate::raw::*; use bytes::Buf; +use opendal_core::EntryMode; +use opendal_core::Error; +use opendal_core::ErrorKind; +use opendal_core::Metadata; +use opendal_core::Result; +use opendal_core::raw::*; pub struct AliyunDriveLister { core: Arc<AliyunDriveCore>, diff --git a/core/core/src/services/aliyun_drive/writer.rs b/core/services/aliyun-drive/src/writer.rs similarity index 96% rename from core/core/src/services/aliyun_drive/writer.rs rename to core/services/aliyun-drive/src/writer.rs index d5f46978b..0727b606c 100644 --- a/core/core/src/services/aliyun_drive/writer.rs +++ b/core/services/aliyun-drive/src/writer.rs @@ -23,8 +23,8 @@ use super::core::AliyunDriveCore; use super::core::CheckNameMode; use super::core::CreateResponse; use super::core::CreateType; -use crate::raw::*; -use crate::*; +use opendal_core::raw::*; +use opendal_core::*; pub struct AliyunDriveWriter { core: Arc<AliyunDriveCore>, @@ -84,10 +84,9 @@ impl oio::Write for AliyunDriveWriter { .core .upload(file_id, upload_id, self.part_number, bs) .await + && err.kind() != ErrorKind::AlreadyExists { - if err.kind() != ErrorKind::AlreadyExists { - return Err(err); - } + return Err(err); }; self.part_number += 1; diff --git a/core/src/lib.rs b/core/src/lib.rs index 64a3c4adc..26b61e08d 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -27,6 +27,8 @@ pub use opendal_core::*; /// Re-export of service implementations. pub mod services { pub use opendal_core::services::*; + #[cfg(feature = "services-aliyun-drive")] + pub use opendal_service_aliyun_drive::*; #[cfg(feature = "services-azblob")] pub use opendal_service_azblob::*; #[cfg(feature = "services-azdls")]
