pinakes-server: warn on backup cleanup failure; add error logging around
`clear_database` Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I903ce59772c16883642c82427be8167a6a6a6964
This commit is contained in:
parent
61eb2335d3
commit
1f7d7ea925
2 changed files with 5 additions and 1 deletions
|
|
@ -31,7 +31,9 @@ pub async fn create_backup(
|
|||
let bytes = tokio::fs::read(&backup_path)
|
||||
.await
|
||||
.map_err(|e| ApiError(pinakes_core::error::PinakesError::Io(e)))?;
|
||||
let _ = tokio::fs::remove_dir_all(&backup_dir).await;
|
||||
if let Err(e) = tokio::fs::remove_dir_all(&backup_dir).await {
|
||||
tracing::warn!(path = %backup_dir.display(), error = %e, "failed to clean up backup temp dir");
|
||||
}
|
||||
|
||||
let disposition = format!("attachment; filename=\"{filename}\"");
|
||||
Ok(
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ pub async fn vacuum_database(
|
|||
pub async fn clear_database(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
tracing::error!("clear_database: all data is being wiped by admin request");
|
||||
state.storage.clear_all_data().await?;
|
||||
tracing::error!("clear_database: all data wiped successfully");
|
||||
Ok(Json(serde_json::json!({"status": "ok"})))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue