Browse Source

chore: upgrade version

pull/8/head v0.5.0
sigoden 3 years ago
parent
commit
54df4633e1
  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 10
      src/server.rs

2
Cargo.lock generated

@ -296,7 +296,7 @@ dependencies = [ @@ -296,7 +296,7 @@ dependencies = [
[[package]]
name = "duf"
version = "0.4.0"
version = "0.5.0"
dependencies = [
"async-walkdir",
"async_zip",

2
Cargo.toml

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
[package]
name = "duf"
version = "0.4.0"
version = "0.5.0"
edition = "2021"
authors = ["sigoden <sigoden@gmail.com>"]
description = "Duf is a simple file server."

10
src/server.rs

@ -268,9 +268,9 @@ impl InnerService { @@ -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::<ETag>()
.unwrap();
let last_modified = LastModified::from(mtime);
@ -395,10 +395,10 @@ enum PathType { @@ -395,10 +395,10 @@ enum PathType {
async fn get_path_item<P: AsRef<Path>>(path: P, base_path: P) -> BoxResult<PathItem> {
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,

Loading…
Cancel
Save