mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
chore: bump deps
This commit is contained in:
11
src/auth.rs
11
src/auth.rs
@@ -1,3 +1,4 @@
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use headers::HeaderValue;
|
||||
use hyper::Method;
|
||||
use lazy_static::lazy_static;
|
||||
@@ -215,8 +216,9 @@ impl AuthMethod {
|
||||
pub fn get_user(&self, authorization: &HeaderValue) -> Option<String> {
|
||||
match self {
|
||||
AuthMethod::Basic => {
|
||||
let value: Vec<u8> =
|
||||
base64::decode(strip_prefix(authorization.as_bytes(), b"Basic ")?).ok()?;
|
||||
let value: Vec<u8> = general_purpose::STANDARD_NO_PAD
|
||||
.decode(strip_prefix(authorization.as_bytes(), b"Basic ")?)
|
||||
.ok()?;
|
||||
let parts: Vec<&str> = std::str::from_utf8(&value).ok()?.split(':').collect();
|
||||
Some(parts[0].to_string())
|
||||
}
|
||||
@@ -239,8 +241,9 @@ impl AuthMethod {
|
||||
) -> Option<()> {
|
||||
match self {
|
||||
AuthMethod::Basic => {
|
||||
let basic_value: Vec<u8> =
|
||||
base64::decode(strip_prefix(authorization.as_bytes(), b"Basic ")?).ok()?;
|
||||
let basic_value: Vec<u8> = general_purpose::STANDARD_NO_PAD
|
||||
.decode(strip_prefix(authorization.as_bytes(), b"Basic ")?)
|
||||
.ok()?;
|
||||
let parts: Vec<&str> = std::str::from_utf8(&basic_value).ok()?.split(':').collect();
|
||||
|
||||
if parts[0] != auth_user {
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::{Args, BoxResult};
|
||||
use walkdir::WalkDir;
|
||||
use xml::escape::escape_str_pcdata;
|
||||
|
||||
use async_zip::write::{EntryOptions, ZipFileWriter};
|
||||
use async_zip::Compression;
|
||||
use async_zip::write::ZipFileWriter;
|
||||
use async_zip::{Compression, ZipEntryBuilder};
|
||||
use chrono::{TimeZone, Utc};
|
||||
use futures::TryStreamExt;
|
||||
use headers::{
|
||||
@@ -1140,7 +1140,10 @@ impl PathItem {
|
||||
}
|
||||
|
||||
pub fn to_dav_xml(&self, prefix: &str) -> String {
|
||||
let mtime = Utc.timestamp_millis(self.mtime as i64).to_rfc2822();
|
||||
let mtime = Utc
|
||||
.timestamp_millis_opt(self.mtime as i64)
|
||||
.unwrap()
|
||||
.to_rfc2822();
|
||||
let mut href = encode_uri(&format!("{}{}", prefix, &self.name));
|
||||
if self.is_dir() && !href.ends_with('/') {
|
||||
href.push('/');
|
||||
@@ -1305,10 +1308,10 @@ async fn zip_dir<W: AsyncWrite + Unpin>(
|
||||
Some(v) => v,
|
||||
None => continue,
|
||||
};
|
||||
let entry_options =
|
||||
EntryOptions::new(filename.to_owned(), Compression::Deflate).unix_permissions(0o644);
|
||||
let builder =
|
||||
ZipEntryBuilder::new(filename.into(), Compression::Deflate).unix_permissions(0o644);
|
||||
let mut file = File::open(&zip_path).await?;
|
||||
let mut file_writer = writer.write_entry_stream(entry_options).await?;
|
||||
let mut file_writer = writer.write_entry_stream(builder).await?;
|
||||
io::copy(&mut file, &mut file_writer).await?;
|
||||
file_writer.close().await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user