make cosmetic changes to state schema, add fileset passwords for forthcoming functionality

This commit is contained in:
xenofem 2022-08-16 06:16:00 -04:00
parent 073feda920
commit aef58d133b
9 changed files with 327 additions and 119 deletions

View file

@ -109,13 +109,7 @@ impl Actor for Uploader {
type Context = <Uploader as Actor>::Context;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct UploadedFile {
pub name: String,
pub size: u64,
#[serde(with = "crate::timestamp")]
pub modtime: OffsetDateTime,
}
pub use crate::state::v1::UploadedFile;
impl UploadedFile {
fn new(name: &str, size: u64, modtime: OffsetDateTime) -> Self {
@ -328,15 +322,14 @@ impl Uploader {
modtime,
expiry: OffsetDateTime::now_utc() + lifetime * time::Duration::DAY,
contents,
password: None,
};
let app_data = self.app_data.clone();
let storage_filename = self.storage_filename.clone();
ctx.spawn(
actix::fut::wrap_future(async move {
debug!("Spawned future to add entry {} to state", storage_filename);
app_data
.add_file(storage_filename, stored_file)
.await
app_data.add_file(storage_filename, stored_file).await
})
.map(|res, u: &mut Self, ctx: &mut Context| match res {
Ok(()) => ctx.text(
@ -406,10 +399,7 @@ impl Uploader {
ctx.wait(
actix::fut::wrap_future(async move {
debug!("Spawned future to remove entry {} from state", filename);
app_data
.remove_file(&filename)
.await
.unwrap();
app_data.remove_file(&filename).await.unwrap();
})
.map(stop_and_flush),
);