Browse Source

feat: aware RUST_LOG

pull/8/head
sigoden 3 years ago
parent
commit
3673a64ec7
  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 2
      README.md
  4. 4
      src/main.rs
  5. 2
      src/server.rs

2
Cargo.lock generated

@ -258,7 +258,7 @@ dependencies = [ @@ -258,7 +258,7 @@ dependencies = [
[[package]]
name = "duf"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"async-walkdir",
"async_zip",

2
Cargo.toml

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

2
README.md

@ -49,8 +49,6 @@ duf --static @@ -49,8 +49,6 @@ duf --static
Finally, run this command to see a list of all available option
### Curl
Download a file

4
src/main.rs

@ -25,6 +25,9 @@ async fn main() { @@ -25,6 +25,9 @@ async fn main() {
async fn run() -> BoxResult<()> {
let args = Args::parse(matches())?;
if std::env::var("RUST_LOG").is_ok() {
simple_logger::init()?;
} else {
let level = if args.log {
LevelFilter::Info
} else {
@ -33,6 +36,7 @@ async fn run() -> BoxResult<()> { @@ -33,6 +36,7 @@ async fn run() -> BoxResult<()> {
simple_logger::SimpleLogger::default()
.with_level(level)
.init()?;
}
serve(args).await
}

2
src/server.rs

@ -187,7 +187,7 @@ impl InnerService { @@ -187,7 +187,7 @@ impl InnerService {
}
async fn handle_send_dir_zip(&self, path: &Path) -> BoxResult<Response> {
let (mut writer, reader) = tokio::io::duplex(65536);
let (mut writer, reader) = tokio::io::duplex(1024 * 1024 * 20);
dir_zip(&mut writer, path).await?;
let stream = ReaderStream::new(reader);
let body = Body::wrap_stream(stream);

Loading…
Cancel
Save