admin/maintenance: sqlite vacuum
This commit is contained in:
parent
ff6c910b2f
commit
37c5127bbc
6 changed files with 52 additions and 12 deletions
|
|
@ -17,6 +17,7 @@ pub fn routes() -> Vec<Route> {
|
|||
settings_security,
|
||||
settings_security_form,
|
||||
settings_maintenance,
|
||||
settings_maintenance_form,
|
||||
admin_apps_list,
|
||||
admin_apps_new,
|
||||
admin_apps_new_form,
|
||||
|
|
|
|||
|
|
@ -209,3 +209,29 @@ pub async fn settings_maintenance(
|
|||
.map(|flash| Page::with_flash(page.clone(), flash))
|
||||
.unwrap_or_else(|| page.into()))
|
||||
}
|
||||
|
||||
#[derive(Debug, FromForm)]
|
||||
pub struct CleanForm {
|
||||
pub vacuum: Option<bool>,
|
||||
}
|
||||
|
||||
#[post("/admin/settings/maintenance", data = "<form>")]
|
||||
pub async fn settings_maintenance_form(
|
||||
mut db: Connection<Database>,
|
||||
_admin: JwtAdmin,
|
||||
form: Form<CleanForm>,
|
||||
) -> Result<Flash<Redirect>> {
|
||||
let (flash_kind, flash_message) = if matches!(form.vacuum, Some(true)) {
|
||||
Settings::vacuum(&mut **db).await?;
|
||||
|
||||
(FlashKind::Success, "Database has been cleaned.")
|
||||
} else {
|
||||
(FlashKind::Warning, "Nothing to do.")
|
||||
};
|
||||
|
||||
Ok(Flash::new(
|
||||
Redirect::to(uri!(settings_maintenance)),
|
||||
flash_kind,
|
||||
flash_message,
|
||||
))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,17 +75,7 @@
|
|||
</div>
|
||||
|
||||
<h3>Do you want to clean the database?</h3>
|
||||
<div class="mt-2">
|
||||
This action will <strong>delete</strong> the following:
|
||||
</div>
|
||||
<ul class="list-inline mt-1">
|
||||
<li>Authorization codes</li>
|
||||
<li>Refresh tokens</li>
|
||||
<li>TOTP requests</li>
|
||||
</ul>
|
||||
<div class="mt-2">
|
||||
This action will be permanent.
|
||||
</div>
|
||||
<div class="mt-2">This might take some time, but should not be long.</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -99,7 +89,7 @@
|
|||
|
||||
<div class="col">
|
||||
<form action="" method="post">
|
||||
<button type="submit" name="clean" value="true" class="btn btn-danger w-100">
|
||||
<button type="submit" name="vacuum" value="true" class="btn btn-danger w-100">
|
||||
Clean database
|
||||
</button>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue