1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-05-21 02:53:56 +00:00

Send deletion thread and updated users revision

This commit is contained in:
Daniel García 2021-03-22 19:57:35 +01:00
parent 46a1a013cd
commit 1fc6c30652
No known key found for this signature in database
GPG key ID: FC8A7D14C3CD543A
6 changed files with 34 additions and 5 deletions

View file

@ -25,6 +25,23 @@ pub fn routes() -> Vec<rocket::Route> {
]
}
pub fn start_send_deletion_scheduler(pool: crate::db::DbPool) {
std::thread::spawn(move || {
loop {
if let Ok(conn) = pool.get() {
info!("Initiating send deletion");
for send in Send::find_all(&conn) {
if chrono::Utc::now().naive_utc() >= send.deletion_date {
send.delete(&conn).ok();
}
}
}
std::thread::sleep(std::time::Duration::from_secs(3600));
}
});
}
#[derive(Deserialize)]
#[allow(non_snake_case)]
pub struct SendData {
@ -370,10 +387,6 @@ fn delete_send(id: String, headers: Headers, conn: DbConn, nt: Notify) -> EmptyR
err!("Send is not owned by user")
}
if send.atype == SendType::File as i32 {
std::fs::remove_dir_all(Path::new(&CONFIG.sends_folder()).join(&send.uuid)).ok();
}
send.delete(&conn)?;
nt.send_user_update(UpdateType::SyncSendDelete, &headers.user);