Skip to content

Commit

Permalink
refactor: Remove not needed types in icloud (#4021)
Browse files Browse the repository at this point in the history
* Save work

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

* refactor: Remove not needed types in icloud

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

* Remove not needed clients

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

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Jan 19, 2024
1 parent 60dcec9 commit 6c8b049
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 392 deletions.
56 changes: 56 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ native-tls-vendored = ["reqwest/native-tls-vendored"]
# Enable path cache.
# This is an internal feature, and should not be used by users.
internal-path-cache = ["dep:moka"]
internal-http-cookies = ["reqwest/cookies"]

# Enable all layers.
layers-all = [
Expand Down Expand Up @@ -154,7 +155,7 @@ services-http = []
services-huggingface = []
services-ipfs = ["dep:prost"]
services-ipmfs = []
services-icloud = ["internal-path-cache"]
services-icloud = ["internal-path-cache", "internal-http-cookies"]
services-koofr = []
services-libsql = ["dep:hrana-client-proto"]
services-memcached = ["dep:bb8"]
Expand Down
2 changes: 2 additions & 0 deletions core/src/raw/http_util/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ impl HttpClient {

#[cfg(feature = "trust-dns")]
let builder = builder.trust_dns(true);
#[cfg(feature = "internal-http-cookies")]
let builder = builder.cookie_store(true);

Ok(Self {
client: builder.build().map_err(|err| {
Expand Down
16 changes: 9 additions & 7 deletions core/src/services/icloud/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ use std::fmt::{Debug, Formatter};
use std::sync::Arc;
use tokio::sync::Mutex;

use super::core::*;
use crate::raw::*;
use crate::*;
use crate::{Capability, Scheme};

use super::core::{parse_error, IcloudCore, IcloudPathQuery, IcloudSigner, SessionData};

/// Config for icloud services support.
#[derive(Default, Deserialize)]
Expand Down Expand Up @@ -146,6 +144,7 @@ impl IcloudBuilder {

self
}

/// ds_web_auth_token must be set in Session
///
/// Avoid Two Factor Authentication
Expand All @@ -158,9 +157,11 @@ impl IcloudBuilder {

self
}
/// Enable the china origin
/// For China, use "https://www.icloud.com.cn"
/// For Other region, use "https://www.icloud.com"

/// Set if your apple id in China mainland.
///
/// If in china mainland, we will connect to `https://www.icloud.com.cn`.
/// Otherwise, we will connect to `https://www.icloud.com`.
pub fn is_china_mainland(&mut self, is_china_mainland: bool) -> &mut Self {
self.config.is_china_mainland = is_china_mainland;
self
Expand Down Expand Up @@ -243,14 +244,15 @@ impl Builder for IcloudBuilder {
trust_token: Some(trust_token),
ds_web_auth_token: Some(ds_web_auth_token),
is_china_mainland: self.config.is_china_mainland,
initiated: false,
};

let signer = Arc::new(Mutex::new(signer));
Ok(IcloudBackend {
core: Arc::new(IcloudCore {
signer: signer.clone(),
root,
path_cache: PathCacher::new(IcloudPathQuery::new(client, signer.clone())),
path_cache: PathCacher::new(IcloudPathQuery::new(signer.clone())),
}),
})
}
Expand Down
Loading

0 comments on commit 6c8b049

Please sign in to comment.