admin command to delete all remote media within the past x time

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-02 11:00:53 -05:00 committed by June
parent 5c94c9c0d4
commit ee548bd2e7
6 changed files with 175 additions and 24 deletions

View file

@ -52,12 +52,11 @@ impl service::media::Data for KeyValueDatabase {
debug!("Deleting key: {:?}", key);
self.mediaid_file.remove(&key)?;
}
//return Err(Error::bad_database("Media not found."));
Ok(())
}
/// Searches for all files with the given MXC (e.g. thumbnail and original image)
/// Searches for all files with the given MXC
fn search_mxc_metadata_prefix(&self, mxc: String) -> Result<Vec<Vec<u8>>> {
debug!("MXC URI: {:?}", mxc);
@ -126,6 +125,17 @@ impl service::media::Data for KeyValueDatabase {
Ok((content_disposition, content_type, key))
}
/// Gets all the media keys in our database (this includes all the metadata associated with it such as width, height, content-type, etc)
fn get_all_media_keys(&self) -> Result<Vec<Vec<u8>>> {
let mut keys: Vec<Vec<u8>> = vec![];
for (key, _) in self.mediaid_file.iter() {
keys.push(key);
}
Ok(keys)
}
fn remove_url_preview(&self, url: &str) -> Result<()> {
self.url_previews.remove(url.as_bytes())
}