1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-08-24 19:53:18 +00:00

Add support for auto-deleting trashed items

Upstream will soon auto-delete trashed items after 30 days, but some people
use the trash as an archive folder, so to avoid unexpected data loss, this
implementation requires the user to explicitly enable auto-deletion.
This commit is contained in:
Jeremy Lin 2021-04-02 20:52:15 -07:00
commit d77333576b
7 changed files with 54 additions and 2 deletions

View file

@ -13,7 +13,7 @@ use crate::{
api::{self, EmptyResult, JsonResult, JsonUpcase, Notify, PasswordData, UpdateType},
auth::Headers,
crypto,
db::{models::*, DbConn},
db::{models::*, DbConn, DbPool},
CONFIG,
};
@ -77,6 +77,15 @@ pub fn routes() -> Vec<Route> {
]
}
pub fn purge_trashed_ciphers(pool: DbPool) {
debug!("Purging trashed ciphers");
if let Ok(conn) = pool.get() {
Cipher::purge_trash(&conn);
} else {
error!("Failed to get DB connection while purging trashed ciphers")
}
}
#[derive(FromForm, Default)]
struct SyncData {
#[form(field = "excludeDomains")]

View file

@ -5,6 +5,7 @@ mod organizations;
pub mod two_factor;
mod sends;
pub use ciphers::purge_trashed_ciphers;
pub use sends::purge_sends;
pub fn routes() -> Vec<Route> {

View file

@ -11,6 +11,7 @@ use serde_json::Value;
pub use crate::api::{
admin::routes as admin_routes,
core::purge_sends,
core::purge_trashed_ciphers,
core::routes as core_routes,
icons::routes as icons_routes,
identity::routes as identity_routes,