mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
add dry-run mode to delete-remote-media-files admin command
This commit is contained in:
parent
9d14c5d461
commit
ba7b224c38
1 changed files with 15 additions and 4 deletions
|
|
@ -189,6 +189,11 @@ enum AdminCommand {
|
|||
///
|
||||
/// This media may still be fetched and cached again in the future.
|
||||
DeleteRemoteMedia {
|
||||
/// Output the number of media objects that would be deleted, but do
|
||||
/// not actually delete anything.
|
||||
#[clap(short, long)]
|
||||
dry_run: bool,
|
||||
|
||||
/// If specified, only delete remote media from this origin.
|
||||
///
|
||||
/// If not specified, all remote media will be deleted.
|
||||
|
|
@ -815,6 +820,7 @@ impl Service {
|
|||
RoomMessageEventContent::text_plain("Media deleted.")
|
||||
}
|
||||
AdminCommand::DeleteRemoteMedia {
|
||||
dry_run,
|
||||
origin,
|
||||
} => {
|
||||
if origin.as_deref() == Some(services().globals.server_name()) {
|
||||
|
|
@ -851,12 +857,17 @@ impl Service {
|
|||
}
|
||||
|
||||
count += 1;
|
||||
services().media.delete(mxc).await?;
|
||||
if !dry_run {
|
||||
services().media.delete(mxc).await?;
|
||||
}
|
||||
}
|
||||
|
||||
RoomMessageEventContent::text_plain(format!(
|
||||
"{count} media objects deleted."
|
||||
))
|
||||
let message = if dry_run {
|
||||
format!("{count} media objects would be deleted.")
|
||||
} else {
|
||||
format!("{count} media objects deleted.")
|
||||
};
|
||||
RoomMessageEventContent::text_plain(message)
|
||||
}
|
||||
AdminCommand::DeactivateUser {
|
||||
leave_rooms,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue