Skip to content

Commit 3ca1c30

Browse files
committed
bak
1 parent 75f20fd commit 3ca1c30

File tree

8 files changed

+69
-93
lines changed

8 files changed

+69
-93
lines changed

Cargo.lock

Lines changed: 38 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ delay_timer = "0.11.6"
2222
duration-str = "0.17"
2323
futures = "0.3"
2424
futures-util = { version = "0.3", default-features = false }
25-
if_chain = "1.0"
2625
indicatif = "0.18"
27-
lazy_static = "1.4"
2826
md-5 = "0.10"
2927
percent-encoding = "2.1"
3028
regex = "1.10"

client/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,4 @@ indicatif = { workspace = true }
4646
md-5 = { workspace = true }
4747
# util
4848
anyhow = { workspace = true, features = ["backtrace"] }
49-
walkdir = { workspace = true }
50-
if_chain = { workspace = true }
49+
walkdir = { workspace = true }

client/src/upload_files.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use entity::request::UpdateUploadingStatusOption;
55
use entity::storage::{GetDomainPositionStatus, ShortMetaData, UploadingStatus};
66
use futures::StreamExt;
77
use futures::future::Either;
8-
use if_chain::if_chain;
98
use md5::{Digest, Md5};
109
use std::borrow::Cow;
1110
use std::collections::HashMap;
@@ -55,27 +54,28 @@ pub async fn upload_files(
5554
.min_depth(1)
5655
.into_iter()
5756
.filter_map(|entity| {
58-
if_chain! {
59-
if let Some(entity) = entity.ok();
60-
if let Some(metadata) = entity.metadata().ok();
61-
if metadata.is_file();
62-
if let Ok(key) = entity.path().strip_prefix(&parent);
63-
then {
64-
let key = key.components().map(|c| c.as_os_str().to_string_lossy())
65-
.collect::<Vec<_>>()
66-
.join("/");
67-
if server_metadata.get(&key).filter(|x|{
68-
let md5 = md5_file(entity.path(), &mut byte_buffer);
69-
x.length == metadata.len() &&
70-
md5.filter(|md5|md5 == &x.md5).is_some()
71-
}).is_none() {
72-
Some((key, entity.path().to_path_buf()))
73-
} else {
74-
None
75-
}
76-
}else {
77-
None
78-
}
57+
let entity = entity.ok()?;
58+
let metadata = entity.metadata().ok()?;
59+
if !metadata.is_file() {
60+
return None;
61+
}
62+
let key = entity.path().strip_prefix(&parent).ok()?;
63+
let key = key
64+
.components()
65+
.map(|c| c.as_os_str().to_string_lossy())
66+
.collect::<Vec<_>>()
67+
.join("/");
68+
if server_metadata
69+
.get(&key)
70+
.filter(|x| {
71+
let md5 = md5_file(entity.path(), &mut byte_buffer);
72+
x.length == metadata.len() && md5.filter(|md5| md5 == &x.md5).is_some()
73+
})
74+
.is_none()
75+
{
76+
Some((key, entity.path().to_path_buf()))
77+
} else {
78+
None
7979
}
8080
})
8181
.collect::<Vec<(String, PathBuf)>>();

server/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ dashmap = { workspace = true }
5555
# util
5656
md-5 = { workspace = true }
5757
regex = { workspace = true }
58-
lazy_static = { workspace = true }
5958
# solve return result
6059
anyhow = { workspace = true, features = ["backtrace"] }
6160
# solve dir walk without recursion

server/src/admin_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl AdminServer {
110110

111111
pub mod service {
112112
use crate::admin_server::bad_resp;
113-
use crate::domain_storage::{DomainStorage, URI_REGEX};
113+
use crate::domain_storage::{DomainStorage, uri_regex};
114114
use entity::request::{
115115
DeleteDomainVersionOption, DomainWithOptVersionOption, DomainWithVersionOption,
116116
GetDomainOption, GetDomainPositionFormat, GetDomainPositionOption,
@@ -189,7 +189,7 @@ pub mod service {
189189
if super::AdminServer::check_alias(&option.domain, host_alias.clone(), res) {
190190
return;
191191
}
192-
if URI_REGEX.is_match(&option.domain) {
192+
if uri_regex().is_match(&option.domain) {
193193
match storage.get_upload_position(&option.domain) {
194194
Ok(ret) => {
195195
if option.format == GetDomainPositionFormat::Json {

0 commit comments

Comments
 (0)