mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
keep going when one deletion fails in delete-remote-media
We *should* ensure that media deletion is always successful, but when a bug causes a single object to fail deletion it's better to try to delete the remaining objects than to give up entirely.
This commit is contained in:
parent
11b5055647
commit
8fcec6396e
1 changed files with 22 additions and 2 deletions
|
|
@ -807,6 +807,7 @@ impl Service {
|
|||
});
|
||||
|
||||
let mut failed_keys = 0;
|
||||
let mut failed_deletes = 0;
|
||||
while let Some(mxc) = rx.recv().await {
|
||||
let Ok(mxc) = mxc else {
|
||||
// Error details are logged by media::iter_all
|
||||
|
|
@ -825,10 +826,18 @@ impl Service {
|
|||
}
|
||||
}
|
||||
|
||||
count += 1;
|
||||
// Technically this can be collapsed, but relying on &&
|
||||
// short-circuiting to avoid the delete side-effect is
|
||||
// confusing.
|
||||
#[allow(clippy::collapsible_if)]
|
||||
if !dry_run {
|
||||
services().media.delete(mxc).await?;
|
||||
if services().media.delete(mxc).await.is_err() {
|
||||
// Error details are logged by media::delete
|
||||
failed_deletes += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
|
||||
let mut message = if dry_run {
|
||||
|
|
@ -844,6 +853,17 @@ impl Service {
|
|||
database."
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if failed_deletes != 0 {
|
||||
write!(
|
||||
message,
|
||||
"\n{failed_deletes} media objects failed to delete."
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if failed_keys != 0 || failed_deletes != 0 {
|
||||
write!(
|
||||
message,
|
||||
"\nCheck the server logs for more details."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue