cargo fmt
This commit is contained in:
parent
cecb0e3db3
commit
80bca69e5e
1 changed files with 23 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::HashSet, fs::File, io::Write, path::Path, path::Component};
|
use std::{collections::HashSet, fs::File, io::Write, path::Component, path::Path};
|
||||||
|
|
||||||
use actix::{fut::future::ActorFutureExt, Actor, ActorContext, AsyncContext, StreamHandler};
|
use actix::{fut::future::ActorFutureExt, Actor, ActorContext, AsyncContext, StreamHandler};
|
||||||
use actix_http::ws::{CloseReason, Item};
|
use actix_http::ws::{CloseReason, Item};
|
||||||
|
@ -30,14 +30,18 @@ fn sanitise_path_component(name: &str, extension_length: usize) -> String {
|
||||||
sanitise_with_options(
|
sanitise_with_options(
|
||||||
&name,
|
&name,
|
||||||
&SanOptions {
|
&SanOptions {
|
||||||
length_limit: SanOptions::DEFAULT.length_limit.saturating_sub(extension_length),
|
length_limit: SanOptions::DEFAULT
|
||||||
|
.length_limit
|
||||||
|
.saturating_sub(extension_length),
|
||||||
..SanOptions::DEFAULT
|
..SanOptions::DEFAULT
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sanitise_path(path: &str) -> String {
|
fn sanitise_path(path: &str) -> String {
|
||||||
let mut san_path = Path::new(path).components().rfold(String::new(), |subpath, c| {
|
let mut san_path = Path::new(path)
|
||||||
|
.components()
|
||||||
|
.rfold(String::new(), |subpath, c| {
|
||||||
if subpath.len() >= SanOptions::DEFAULT.length_limit * 8 {
|
if subpath.len() >= SanOptions::DEFAULT.length_limit * 8 {
|
||||||
return subpath;
|
return subpath;
|
||||||
}
|
}
|
||||||
|
@ -306,8 +310,9 @@ impl Uploader {
|
||||||
if files.len() > 1 {
|
if files.len() > 1 {
|
||||||
info!("Wrapping in zipfile generator");
|
info!("Wrapping in zipfile generator");
|
||||||
let now = OffsetDateTime::now_utc();
|
let now = OffsetDateTime::now_utc();
|
||||||
let collection_name =
|
let collection_name = collection_name
|
||||||
collection_name.map(|f| sanitise_path_component(&f, 4)).unwrap_or_else(|| {
|
.map(|f| sanitise_path_component(&f, 4))
|
||||||
|
.unwrap_or_else(|| {
|
||||||
super::APP_NAME.to_owned()
|
super::APP_NAME.to_owned()
|
||||||
+ &now.format(FILENAME_DATE_FORMAT).unwrap()
|
+ &now.format(FILENAME_DATE_FORMAT).unwrap()
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue