diff --git a/Cargo.lock b/Cargo.lock index b311f77..4e2c794 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -296,7 +296,7 @@ dependencies = [ [[package]] name = "duf" -version = "0.4.0" +version = "0.5.0" dependencies = [ "async-walkdir", "async_zip", diff --git a/Cargo.toml b/Cargo.toml index 47d94fd..4b12be7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "duf" -version = "0.4.0" +version = "0.5.0" edition = "2021" authors = ["sigoden "] description = "Duf is a simple file server." diff --git a/src/server.rs b/src/server.rs index 28dec09..6a616ca 100644 --- a/src/server.rs +++ b/src/server.rs @@ -268,9 +268,9 @@ impl InnerService { let (file, meta) = (file?, meta?); let mut res = Response::default(); if let Ok(mtime) = meta.modified() { - let mtime_value = get_timestamp(&mtime); + let timestamp = get_timestamp(&mtime); let size = meta.len(); - let etag = format!(r#""{}-{}""#, mtime_value, size) + let etag = format!(r#""{}-{}""#, timestamp, size) .parse::() .unwrap(); let last_modified = LastModified::from(mtime); @@ -395,10 +395,10 @@ enum PathType { async fn get_path_item>(path: P, base_path: P) -> BoxResult { let path = path.as_ref(); let rel_path = path.strip_prefix(base_path).unwrap(); - let meta = fs::metadata(&path).await?; - let s_meta = fs::symlink_metadata(&path).await?; + let (meta, meta2) = tokio::join!(fs::metadata(&path), fs::symlink_metadata(&path)); + let (meta, meta2) = (meta?, meta2?); let is_dir = meta.is_dir(); - let is_symlink = s_meta.file_type().is_symlink(); + let is_symlink = meta2.file_type().is_symlink(); let path_type = match (is_symlink, is_dir) { (true, true) => PathType::SymlinkDir, (false, true) => PathType::Dir,