fix: release db connection

This commit is contained in:
kieran 2025-01-25 23:52:42 +00:00
parent 0bd531a21d
commit 71f6f47a00
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -389,7 +389,12 @@ pub async fn get_blob_thumb(
if id.len() != 32 { if id.len() != 32 {
return Err(Status::NotFound); return Err(Status::NotFound);
} }
if let Ok(Some(info)) = db.get_file(&id).await { let info = if let Ok(Some(info)) = db.get_file(&id).await {
info
} else {
return Err(Status::NotFound);
};
let file_path = fs.get(&id); let file_path = fs.get(&id);
let mut thumb_file = temp_dir().join(format!("thumb_{}", sha256)); let mut thumb_file = temp_dir().join(format!("thumb_{}", sha256));
@ -403,17 +408,17 @@ pub async fn get_blob_thumb(
}; };
if let Ok(f) = File::open(&thumb_file).await { if let Ok(f) = File::open(&thumb_file).await {
return Ok(FilePayload { Ok(FilePayload {
file: f, file: f,
info: FileUpload { info: FileUpload {
size: thumb_file.metadata().unwrap().len(), size: thumb_file.metadata().unwrap().len(),
mime_type: "image/webp".to_string(), mime_type: "image/webp".to_string(),
..info ..info
}, },
}); })
} } else {
}
Err(Status::NotFound) Err(Status::NotFound)
}
} }
/// Legacy URL redirect for void.cat uploads /// Legacy URL redirect for void.cat uploads