give zipped files a containing directory to unzip into
This commit is contained in:
parent
faf018a0a5
commit
e05886aac5
6 changed files with 126 additions and 69 deletions
|
|
@ -11,6 +11,7 @@ use rand::{
|
|||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use serde_with::{serde_as, PickFirst, FromInto};
|
||||
use time::OffsetDateTime;
|
||||
use tokio::{
|
||||
fs::File,
|
||||
|
|
@ -18,6 +19,7 @@ use tokio::{
|
|||
};
|
||||
|
||||
use crate::upload::UploadedFile;
|
||||
use crate::zip::FileSet;
|
||||
|
||||
const STATE_FILE_NAME: &str = "files.json";
|
||||
const MAX_STORAGE_FILES: usize = 1024;
|
||||
|
|
@ -36,6 +38,7 @@ pub fn is_valid_storage_code(s: &str) -> bool {
|
|||
.all(|c| c.is_ascii_alphanumeric() || c == &b'-')
|
||||
}
|
||||
|
||||
#[serde_as]
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct StoredFile {
|
||||
|
|
@ -45,7 +48,9 @@ pub struct StoredFile {
|
|||
pub modtime: OffsetDateTime,
|
||||
#[serde(with = "crate::timestamp")]
|
||||
pub expiry: OffsetDateTime,
|
||||
pub contents: Option<Vec<UploadedFile>>,
|
||||
#[serde_as(as = "Option<PickFirst<(_, FromInto<Vec<UploadedFile>>)>>")]
|
||||
#[serde(default)]
|
||||
pub contents: Option<FileSet>,
|
||||
}
|
||||
|
||||
async fn is_valid_entry(key: &str, info: &StoredFile, storage_dir: &Path) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue