Skip to content

Commit 8598ceb

Browse files
committed
bak
1 parent d90f59e commit 8598ceb

File tree

2 files changed

+19
-26
lines changed

2 files changed

+19
-26
lines changed

server/src/domain_storage.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
use crate::acme::ACMEManager;
12
use crate::config::get_host_path_from_domain;
23
use crate::file_cache::{CacheItem, FileCache};
34
use anyhow::{anyhow, bail, Context};
5+
use chrono::{DateTime, Utc};
46
use dashmap::DashMap;
57
use lazy_static::lazy_static;
68
use md5::{Digest, Md5};
@@ -13,11 +15,9 @@ use std::io::{Read, Write};
1315
use std::ops::RangeInclusive;
1416
use std::path::{Path, PathBuf};
1517
use std::sync::Arc;
16-
use chrono::{DateTime, Utc};
1718
use tracing::{debug, info};
1819
use walkdir::{DirEntry, WalkDir};
1920
use warp::fs::sanitize_path;
20-
use crate::acme::ACMEManager;
2121

2222
pub(crate) const URI_REGEX_STR: &str =
2323
"[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\\.?";
@@ -198,7 +198,7 @@ impl DomainStorage {
198198
let mut max_version = 0;
199199
let mut uploading_version = None;
200200
if !domain_dir.exists() {
201-
return Ok((None, None))
201+
return Ok((None, None));
202202
}
203203
for version_dir_entry in fs::read_dir(domain_dir)? {
204204
let version_dir_entry = version_dir_entry?;
@@ -536,18 +536,17 @@ impl DomainStorage {
536536
}
537537
}
538538
pub fn check_if_empty_index(&self, host: &str, path: &str) -> bool {
539-
match self.meta
540-
.get(host) {
541-
Some(v) => {
542-
match v.value() {
543-
DomainMeta::OneWeb { .. } => path.is_empty(),
544-
DomainMeta::MultipleWeb(map) => {
545-
if path.len() > 1 {
546-
map.contains_key(&path[1..])
547-
} else {
548-
map.contains_key(path)
549-
}
550-
}
539+
match self.meta.get(host) {
540+
Some(v) => match v.value() {
541+
DomainMeta::OneWeb { .. } => path.is_empty(),
542+
DomainMeta::MultipleWeb(map) => {
543+
let result = if path.len() > 1 {
544+
map.contains_key(&path[1..])
545+
} else {
546+
map.contains_key(path)
547+
};
548+
debug!("fuck, {},{}, {}", path.len(), path, result);
549+
result
551550
}
552551
},
553552
None => {
@@ -611,7 +610,9 @@ impl DomainStorage {
611610
"domain:{}, version:{} change to upload status:finish",
612611
domain, version
613612
);
614-
acme_manager.add_new_domain(get_host_path_from_domain(&domain).0).await;
613+
acme_manager
614+
.add_new_domain(get_host_path_from_domain(&domain).0)
615+
.await;
615616
}
616617
} else if uploading_status == UploadingStatus::Uploading {
617618
if self
@@ -757,7 +758,6 @@ pub struct CertInfo {
757758
pub host: String,
758759
}
759760

760-
761761
#[cfg(test)]
762762
mod test {
763763
use crate::config::Config;

tests/tests/common.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use reqwest::header::CACHE_CONTROL;
1+
use reqwest::header::{CACHE_CONTROL, LOCATION};
22
use reqwest::redirect::Policy;
33
use reqwest::{ClientBuilder, StatusCode, Url};
44
use spa_client::api::API;
@@ -155,18 +155,11 @@ pub async fn assert_redirect_correct(request_prefix: &str, target_prefix: &str)
155155
.unwrap();
156156
let query = [("lang", "rust"), ("browser", "servo"), ("zh", "转义字符")];
157157
let url = Url::parse_with_params(request_prefix, &query).unwrap();
158-
println!("{}", url);
159-
let path = url.path();
160158
let query = url.query().unwrap();
161159
let response = client.get(url.clone()).send().await.unwrap();
162160
assert_eq!(response.status(), StatusCode::MOVED_PERMANENTLY);
163161
assert_eq!(
164-
response
165-
.headers()
166-
.get("location")
167-
.unwrap()
168-
.to_str()
169-
.unwrap(),
162+
response.headers().get(LOCATION).unwrap().to_str().unwrap(),
170163
format!("{target_prefix}?{query}") //format!("{path}/?{query}")
171164
);
172165
}

0 commit comments

Comments
 (0)