M_NOT_YET_UPLOAD and can not override,and change the result asyncupload to pass

This commit is contained in:
Donjuanplatinum
2026-03-08 19:52:11 +08:00
parent ad896bb091
commit c960a9dbc3
3 changed files with 17 additions and 7 deletions

View File

@@ -60,6 +60,9 @@ pub(super) fn bad_request_code(kind: &ErrorKind) -> StatusCode {
// 429
| LimitExceeded { .. } => StatusCode::TOO_MANY_REQUESTS,
// 409
| CannotOverwriteMedia => StatusCode::CONFLICT,
// 413
| TooLarge => StatusCode::PAYLOAD_TOO_LARGE,
@@ -69,6 +72,9 @@ pub(super) fn bad_request_code(kind: &ErrorKind) -> StatusCode {
// 404
| NotFound | NotImplemented | FeatureDisabled => StatusCode::NOT_FOUND,
// 504
| NotYetUploaded => StatusCode::GATEWAY_TIMEOUT,
// 403
| GuestAccessForbidden
| ThreepidAuthFailed

View File

@@ -159,6 +159,10 @@ impl Service {
) -> Result<()> {
let pending = self.db.search_pending_mxc(mxc).await;
let Some((owner_id, expires_at)) = pending else {
if self.get_metadata(mxc).await.is_some() {
return Err!(Request(CannotOverwriteMedia("Media ID already has content")));
}
return Err!(Request(NotFound("Media not found")));
};