chore: upgrade version
This commit is contained in:
parent
6b293c0f2e
commit
54df4633e1
3 changed files with 7 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -296,7 +296,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "duf"
|
name = "duf"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-walkdir",
|
"async-walkdir",
|
||||||
"async_zip",
|
"async_zip",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "duf"
|
name = "duf"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["sigoden <sigoden@gmail.com>"]
|
authors = ["sigoden <sigoden@gmail.com>"]
|
||||||
description = "Duf is a simple file server."
|
description = "Duf is a simple file server."
|
||||||
|
|
|
@ -268,9 +268,9 @@ impl InnerService {
|
||||||
let (file, meta) = (file?, meta?);
|
let (file, meta) = (file?, meta?);
|
||||||
let mut res = Response::default();
|
let mut res = Response::default();
|
||||||
if let Ok(mtime) = meta.modified() {
|
if let Ok(mtime) = meta.modified() {
|
||||||
let mtime_value = get_timestamp(&mtime);
|
let timestamp = get_timestamp(&mtime);
|
||||||
let size = meta.len();
|
let size = meta.len();
|
||||||
let etag = format!(r#""{}-{}""#, mtime_value, size)
|
let etag = format!(r#""{}-{}""#, timestamp, size)
|
||||||
.parse::<ETag>()
|
.parse::<ETag>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let last_modified = LastModified::from(mtime);
|
let last_modified = LastModified::from(mtime);
|
||||||
|
@ -395,10 +395,10 @@ enum PathType {
|
||||||
async fn get_path_item<P: AsRef<Path>>(path: P, base_path: P) -> BoxResult<PathItem> {
|
async fn get_path_item<P: AsRef<Path>>(path: P, base_path: P) -> BoxResult<PathItem> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let rel_path = path.strip_prefix(base_path).unwrap();
|
let rel_path = path.strip_prefix(base_path).unwrap();
|
||||||
let meta = fs::metadata(&path).await?;
|
let (meta, meta2) = tokio::join!(fs::metadata(&path), fs::symlink_metadata(&path));
|
||||||
let s_meta = fs::symlink_metadata(&path).await?;
|
let (meta, meta2) = (meta?, meta2?);
|
||||||
let is_dir = meta.is_dir();
|
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) {
|
let path_type = match (is_symlink, is_dir) {
|
||||||
(true, true) => PathType::SymlinkDir,
|
(true, true) => PathType::SymlinkDir,
|
||||||
(false, true) => PathType::Dir,
|
(false, true) => PathType::Dir,
|
||||||
|
|
Loading…
Reference in a new issue