Skip to content

Commit b4dbb04

Browse files
committed
bak it
1 parent 1d09ed9 commit b4dbb04

File tree

13 files changed

+74
-192
lines changed

13 files changed

+74
-192
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ members = [
1010
[workspace.package]
1111
authors = ["timzaak <[email protected]>"]
1212
edition = "2021"
13-
version = "2.4.1"
13+
version = "3.0.0"
1414

1515
[workspace.dependencies]
1616
anyhow = { version = "1.0" }

client/src/upload_files.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,19 @@ async fn get_upload_version(api: &API, domain: &str, version: Option<u32>) -> an
203203
}
204204
}
205205

206-
fn md5_file(path: impl AsRef<Path>, byte_buffer: &mut Vec<u8>) -> Option<String> {
207-
File::open(path)
208-
.ok()
209-
.map(|mut f| {
210-
let mut hasher = Md5::new();
211-
//if file_size > 1024 * 1024 {
212-
//1Mb
213-
loop {
214-
let n = f.read(byte_buffer).ok()?;
215-
let valid_buf_slice = &byte_buffer[..n];
216-
if n == 0 {
217-
break;
218-
}
219-
hasher.update(valid_buf_slice);
206+
fn md5_file(path: impl AsRef<Path>, byte_buffer: &mut [u8]) -> Option<String> {
207+
File::open(path).ok().and_then(|mut f| {
208+
let mut hasher = Md5::new();
209+
//if file_size > 1024 * 1024 {
210+
//1Mb
211+
loop {
212+
let n = f.read(byte_buffer).ok()?;
213+
let valid_buf_slice = &byte_buffer[..n];
214+
if n == 0 {
215+
break;
220216
}
221-
Some(format!("{:x}", hasher.finalize()))
222-
})
223-
.flatten()
217+
hasher.update(valid_buf_slice);
218+
}
219+
Some(format!("{:x}", hasher.finalize()))
220+
})
224221
}

entity/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ authors.workspace = true
88
[dependencies]
99
serde = { workspace = true, features = ["derive"] }
1010
serde_repr = { workspace = true }
11-
serde_json = { workspace = true }
12-
duration-str = { workspace = true }
1311
chrono = { workspace = true, features = ["serde"] }

jsclient/src/command.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,6 @@ const release = command({
110110
}
111111
})
112112

113-
const reload = command({
114-
name: 'reload',
115-
args: {config: configDirOption,},
116-
handler({config}) {
117-
writeResult(async () => {
118-
const client = await getClient(config)
119-
await client.reloadSPAServer()
120-
return chalk.green("reload successful")
121-
})
122-
}
123-
})
124113
const deleteCmd = command({
125114
name: 'delete',
126115
args: {
@@ -157,7 +146,7 @@ export const cmd = subcommands({
157146
name: 'spa-client',
158147
description: 'js command line for spa-server',
159148
version: Version,
160-
cmds: {info, upload, release, reload, delete: deleteCmd, revoke: revokeVersionCmd}
149+
cmds: {info, upload, release, delete: deleteCmd, revoke: revokeVersionCmd}
161150
})
162151
export default function runCommand() {
163152
run(binary(cmd), process.argv)

jsclient/src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ export default class SPAClient {
8989
}).then(resp<string>)
9090
}
9191

92-
public reloadSPAServer() {
93-
return this.http.post('/reload').then(emptyResp)
94-
}
95-
96-
9792
public removeFiles(domain?: string, maxReserve?: number) {
9893
return this.http.post('/files/delete', {domain, max_reserve: maxReserve}).then(emptyResp)
9994
}

server/src/admin_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ mod test {
479479
assert!(task.is_valid());
480480
for _ in 0..10 {
481481
let time = task.get_next_exec_timestamp().unwrap() as i64;
482-
let time = NaiveDateTime::from_timestamp_opt(time, 0).unwrap();
483-
let time: DateTime<Utc> = DateTime::from_utc(time, Utc);
482+
483+
let time = DateTime::from_timestamp_millis(time).unwrap();
484484
println!("{}", time.format("%Y-%m-%d %H:%M:%S"));
485485
}
486486
let delay_timer = DelayTimerBuilder::default()

server/src/config.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,3 @@ impl<'de> Deserialize<'de> for OriginWrapper {
153153
))
154154
}
155155
}
156-
157-
#[cfg(test)]
158-
mod test {
159-
use std::env;
160-
use std::path::PathBuf;
161-
162-
fn get_project_path() -> PathBuf {
163-
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
164-
let path = path.parent().unwrap();
165-
path.to_owned()
166-
}
167-
}

server/src/domain_storage.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl DomainStorage {
171171
}
172172

173173
fn get_multiple_path_data(
174-
domain_dir: &PathBuf,
174+
domain_dir: &Path,
175175
domain_dir_name: &str,
176176
multiple_web_path: &PathBuf,
177177
) -> anyhow::Result<Vec<(PathBuf, String, String)>> {
@@ -711,24 +711,21 @@ impl DomainStorage {
711711
}
712712
}
713713

714-
pub fn md5_file(path: impl AsRef<Path>, byte_buffer: &mut Vec<u8>) -> Option<String> {
715-
File::open(path)
716-
.ok()
717-
.map(|mut f| {
718-
let mut hasher = Md5::new();
719-
//if file_size > 1024 * 1024 {
720-
//1Mb
721-
loop {
722-
let n = f.read(byte_buffer).ok()?;
723-
let valid_buf_slice = &byte_buffer[..n];
724-
if n == 0 {
725-
break;
726-
}
727-
hasher.update(valid_buf_slice);
714+
pub fn md5_file(path: impl AsRef<Path>, byte_buffer: &mut [u8]) -> Option<String> {
715+
File::open(path).ok().and_then(|mut f| {
716+
let mut hasher = Md5::new();
717+
//if file_size > 1024 * 1024 {
718+
//1Mb
719+
loop {
720+
let n = f.read(byte_buffer).ok()?;
721+
let valid_buf_slice = &byte_buffer[..n];
722+
if n == 0 {
723+
break;
728724
}
729-
Some(format!("{:x}", hasher.finalize()))
730-
})
731-
.flatten()
725+
hasher.update(valid_buf_slice);
726+
}
727+
Some(format!("{:x}", hasher.finalize()))
728+
})
732729
}
733730

734731
pub fn sanitize_path(base: impl AsRef<Path>, tail: &str) -> Result<PathBuf, Rejection> {

server/src/file_cache.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use hyper::body::Bytes;
44
use lazy_static::lazy_static;
55
use std::collections::HashMap;
66
use std::collections::HashSet;
7-
use std::fs::File;
8-
use std::io::{BufReader, Read};
97
use std::path::PathBuf;
108
use std::sync::Arc;
119
use walkdir::WalkDir;
@@ -103,17 +101,21 @@ impl FileCache {
103101
if let Ok(metadata) = entry.metadata() {
104102
if metadata.is_file() {
105103
if let Ok(key) = entry.path().strip_prefix(&parent) {
106-
let key = key.components()
104+
let key = key
105+
.components()
107106
.map(|c| c.as_os_str().to_string_lossy())
108107
.collect::<Vec<_>>()
109108
.join("/");
110109
let key = sub_path
111110
.map(|sub_path| format!("{sub_path}/{key}"))
112111
.unwrap_or(key);
113-
return Some((key , Arc::new(CacheItem {
114-
data: entry.path().to_path_buf(),
115-
version,
116-
})))
112+
return Some((
113+
key,
114+
Arc::new(CacheItem {
115+
data: entry.path().to_path_buf(),
116+
version,
117+
}),
118+
));
117119
}
118120
}
119121
}

0 commit comments

Comments
 (0)