古いリモートメディアのパージ
- https://matrix-org.github.io/synapse/latest/admin_api/media_admin_api.html#purge-remote-media-api
POST /_synapse/admin/v1/purge_media_cache?before_ts=<unix_timestamp_in_ms>
リモートメディアの総サイズ
matrix1=> select count(*) , sum(media_length) from remote_media_cache;
count | sum
-------+------------
7184 | 4846156363
(1 row)
ローカルメディアの総サイズ
select count(*) , sum(media_length) from local_media_repository;
count | sum
-------+------------
17082 | 7767821172
(1 row)
ユーザ別メディアデータ使用量
select user_id, count(*) as c, sum(media_length) as bytes
from local_media_repository
group by user_id order by bytes desc limit 20;
user_id | c | bytes
---------------------------------------+------+-----------
(CENSORED)
ユーザのメディアデータを削除
login();
for my $userId (@_){
say "#################";
say "$userId";
my $userIdEncoded = uri_escape( $userId );
for(;;){
my $response = eval{
jsonRequest(
DELETE => "/_synapse/admin/v1/users/$userIdEncoded/media"
);
};
if($@){
warn $@,"\n";
last;
}
say dump $response;
my $deleteCount = $response->{total};
last if not $deleteCount;
}
}
古いローカルメディアを削除
- https://matrix-org.github.io/synapse/latest/admin_api/media_admin_api.html#delete-local-media-by-date-or-size
- デフォルトではプロフに使ってる画像は削除されない
login();
my $before_ts = (time - 86400*40)*1000;
for(;;){
my $response = eval{
jsonRequest(
POST=>"/_synapse/admin/v1/media/delete?before_ts=$before_ts"
);
};
if( $@ ){
if( $@ =~ /"error":"([^"]+)"/ ){
say "medieLocalOldDelete: $1";
return;
}else{
die $@;
}
}
say dump($response);
my $deleteCount = $response->{total};
last if not $deleteCount;
}
You must log in or register to comment.