mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Produce even more informative errors when saving media fails
This commit is contained in:
1 parent
20f741d0e5
commit
799def70dc
1 file changed
+14
-9
@@ -90,17 +90,22 @@ impl Service {
|
|||||||
file: &[u8],
|
file: &[u8],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// Width, Height = 0 if it's not a thumbnail
|
// Width, Height = 0 if it's not a thumbnail
|
||||||
let key = self.db.create_file_metadata(
|
let key = self
|
||||||
mxc,
|
.db
|
||||||
user,
|
.create_file_metadata(mxc, user, &Dim::default(), content_disposition, content_type)
|
||||||
&Dim::default(),
|
.map_err(|e| {
|
||||||
content_disposition,
|
err!(Database(error!("Failed to create media metadata for MXC {mxc}: {e}")))
|
||||||
content_type,
|
})?;
|
||||||
)?;
|
|
||||||
|
|
||||||
//TODO: Dangling metadata in database if creation fails
|
//TODO: Dangling metadata in database if creation fails
|
||||||
let mut f = self.create_media_file(&key).await?;
|
let mut f = self.create_media_file(&key).await.map_err(|e| {
|
||||||
f.write_all(file).await?;
|
err!(Database(error!(
|
||||||
|
"Failed to create media file for MXC {mxc} at key {key:?}: {e}"
|
||||||
|
)))
|
||||||
|
})?;
|
||||||
|
f.write_all(file).await.map_err(|e| {
|
||||||
|
err!(Database(error!("Failed to write media file for MXC {mxc} at key {key:?}: {e}")))
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user