mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 23:31:24 +01:00
log details of failed media deletion
This commit is contained in:
parent
bdb623cb07
commit
11b5055647
1 changed files with 19 additions and 4 deletions
|
|
@ -8,7 +8,7 @@ use tokio::{
|
|||
};
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use crate::{services, Result};
|
||||
use crate::{services, utils, Result};
|
||||
|
||||
mod data;
|
||||
|
||||
|
|
@ -114,14 +114,29 @@ impl Service {
|
|||
/// Deletes a media object and all associated thumbnails.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub(crate) async fn delete(&self, mxc: OwnedMxcUri) -> Result<()> {
|
||||
let (_, key) = self.db.search_file_metadata(mxc.clone(), 0, 0)?;
|
||||
let (_, key) =
|
||||
self.db.search_file_metadata(mxc.clone(), 0, 0).inspect_err(
|
||||
|error| warn!(%error, "Failed to find original media key"),
|
||||
)?;
|
||||
|
||||
let thumbnails = self.db.search_thumbnails_metadata(mxc)?;
|
||||
for (_, thumbnail_key) in thumbnails {
|
||||
self.delete_by_key(thumbnail_key).await?;
|
||||
self.delete_by_key(thumbnail_key.clone()).await.inspect_err(
|
||||
|error| {
|
||||
warn!(
|
||||
thumbnail_key = utils::u8_slice_to_hex(
|
||||
thumbnail_key.as_bytes()
|
||||
),
|
||||
%error,
|
||||
"Failed to delete thumbnail media"
|
||||
);
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
||||
self.delete_by_key(key).await?;
|
||||
self.delete_by_key(key).await.inspect_err(
|
||||
|error| warn!(%error, "Failed to delete original media"),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue