mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +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.
|
/// This media may still be fetched and cached again in the future.
|
||||||
DeleteRemoteMedia {
|
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 specified, only delete remote media from this origin.
|
||||||
///
|
///
|
||||||
/// If not specified, all remote media will be deleted.
|
/// If not specified, all remote media will be deleted.
|
||||||
|
|
@ -815,6 +820,7 @@ impl Service {
|
||||||
RoomMessageEventContent::text_plain("Media deleted.")
|
RoomMessageEventContent::text_plain("Media deleted.")
|
||||||
}
|
}
|
||||||
AdminCommand::DeleteRemoteMedia {
|
AdminCommand::DeleteRemoteMedia {
|
||||||
|
dry_run,
|
||||||
origin,
|
origin,
|
||||||
} => {
|
} => {
|
||||||
if origin.as_deref() == Some(services().globals.server_name()) {
|
if origin.as_deref() == Some(services().globals.server_name()) {
|
||||||
|
|
@ -851,12 +857,17 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
|
if !dry_run {
|
||||||
services().media.delete(mxc).await?;
|
services().media.delete(mxc).await?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RoomMessageEventContent::text_plain(format!(
|
let message = if dry_run {
|
||||||
"{count} media objects deleted."
|
format!("{count} media objects would be deleted.")
|
||||||
))
|
} else {
|
||||||
|
format!("{count} media objects deleted.")
|
||||||
|
};
|
||||||
|
RoomMessageEventContent::text_plain(message)
|
||||||
}
|
}
|
||||||
AdminCommand::DeactivateUser {
|
AdminCommand::DeactivateUser {
|
||||||
leave_rooms,
|
leave_rooms,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue