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:
raf 2026-03-12 20:48:15 +03:00
commit 1f7d7ea925
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 5 additions and 1 deletions

View file

@ -31,7 +31,9 @@ pub async fn create_backup(
let bytes = tokio::fs::read(&backup_path) let bytes = tokio::fs::read(&backup_path)
.await .await
.map_err(|e| ApiError(pinakes_core::error::PinakesError::Io(e)))?; .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}\""); let disposition = format!("attachment; filename=\"{filename}\"");
Ok( Ok(

View file

@ -26,6 +26,8 @@ pub async fn vacuum_database(
pub async fn clear_database( pub async fn clear_database(
State(state): State<AppState>, State(state): State<AppState>,
) -> Result<Json<serde_json::Value>, ApiError> { ) -> Result<Json<serde_json::Value>, ApiError> {
tracing::error!("clear_database: all data is being wiped by admin request");
state.storage.clear_all_data().await?; state.storage.clear_all_data().await?;
tracing::error!("clear_database: all data wiped successfully");
Ok(Json(serde_json::json!({"status": "ok"}))) Ok(Json(serde_json::json!({"status": "ok"})))
} }