Skip to content

Commit

Permalink
Make read buffer size configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Aug 20, 2021
1 parent 1779860 commit c509da3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ FLAGS:
-V, --version Prints version information

OPTIONS:
-W, --auth-password <auth-password> WebDav authentication password
-U, --auth-user <auth-user> WebDav authentication username
--host <host> Listen host [default: 127.0.0.1]
-p, --port <port> Listen port [default: 8080]
-r, --refresh-token <refresh-token> Aliyun drive refresh token [env: REFRESH_TOKEN=]
-W, --auth-password <auth-password> WebDav authentication password
-U, --auth-user <auth-user> WebDav authentication username
--host <host> Listen host [default: 127.0.0.1]
-p, --port <port> Listen port [default: 8080]
-S, --read-buffer-size <read-buffer-size>
Read/download buffer size in bytes, defaults to 10MB [default: 10485760]

-r, --refresh-token <refresh-token> Aliyun drive refresh token [env: REFRESH_TOKEN=]
```

### 获取 refresh_token
Expand Down
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct Opt {
/// Automatically generate index.html
#[structopt(short = "I", long)]
auto_index: bool,
/// Read/download buffer size in bytes, defaults to 10MB
#[structopt(short = "S", long, default_value = "10485760")]
read_buffer_size: usize,
}

#[tokio::main(flavor = "multi_thread")]
Expand Down Expand Up @@ -62,10 +65,14 @@ async fn main() -> anyhow::Result<()> {
let dav_server = DavHandler::builder()
.filesystem(Box::new(fs))
.locksystem(MemLs::new())
.read_buf_size(10 * 1024 * 1024) // 10MB
.read_buf_size(opt.read_buffer_size)
.autoindex(opt.auto_index)
.build_handler();
debug!("webdav handler initialized");
debug!(
read_buffer_size = opt.read_buffer_size,
auto_index = opt.auto_index,
"webdav handler initialized"
);

let addr = (opt.host, opt.port)
.to_socket_addrs()
Expand Down

0 comments on commit c509da3

Please sign in to comment.