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

View File

@@ -159,6 +159,10 @@ impl Service {
) -> Result<()> { ) -> Result<()> {
let pending = self.db.search_pending_mxc(mxc).await; let pending = self.db.search_pending_mxc(mxc).await;
let Some((owner_id, expires_at)) = pending else { 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"))); return Err!(Request(NotFound("Media not found")));
}; };

View File

@@ -9,13 +9,13 @@
{"Action":"pass","Test":"TestArchivedRoomsHistory/timeline_is_empty"} {"Action":"pass","Test":"TestArchivedRoomsHistory/timeline_is_empty"}
{"Action":"skip","Test":"TestArchivedRoomsHistory/timeline_is_empty/incremental_sync"} {"Action":"skip","Test":"TestArchivedRoomsHistory/timeline_is_empty/incremental_sync"}
{"Action":"pass","Test":"TestArchivedRoomsHistory/timeline_is_empty/initial_sync"} {"Action":"pass","Test":"TestArchivedRoomsHistory/timeline_is_empty/initial_sync"}
{"Action":"fail","Test":"TestAsyncUpload"} {"Action":"pass","Test":"TestAsyncUpload"}
{"Action":"fail","Test":"TestAsyncUpload/Cannot_upload_to_a_media_ID_that_has_already_been_uploaded_to"} {"Action":"pass","Test":"TestAsyncUpload/Cannot_upload_to_a_media_ID_that_has_already_been_uploaded_to"}
{"Action":"fail","Test":"TestAsyncUpload/Create_media"} {"Action":"pass","Test":"TestAsyncUpload/Create_media"}
{"Action":"fail","Test":"TestAsyncUpload/Download_media"} {"Action":"pass","Test":"TestAsyncUpload/Download_media"}
{"Action":"fail","Test":"TestAsyncUpload/Download_media_over__matrix/client/v1/media/download"} {"Action":"pass","Test":"TestAsyncUpload/Download_media_over__matrix/client/v1/media/download"}
{"Action":"fail","Test":"TestAsyncUpload/Not_yet_uploaded"} {"Action":"pass","Test":"TestAsyncUpload/Not_yet_uploaded"}
{"Action":"fail","Test":"TestAsyncUpload/Upload_media"} {"Action":"pass","Test":"TestAsyncUpload/Upload_media"}
{"Action":"pass","Test":"TestAvatarUrlUpdate"} {"Action":"pass","Test":"TestAvatarUrlUpdate"}
{"Action":"pass","Test":"TestBannedUserCannotSendJoin"} {"Action":"pass","Test":"TestBannedUserCannotSendJoin"}
{"Action":"skip","Test":"TestCanRegisterAdmin"} {"Action":"skip","Test":"TestCanRegisterAdmin"}