diff --git a/swh/deposit/api/common.py b/swh/deposit/api/common.py --- a/swh/deposit/api/common.py +++ b/swh/deposit/api/common.py @@ -326,7 +326,7 @@ def _check_preconditions_on( self, filehandler, md5sum: Optional[bytes], content_length: Optional[int] = None - ) -> Optional[Dict]: + ) -> None: """Check preconditions on provided file are respected. That is the length and/or the md5sum hash match the file's content. @@ -363,8 +363,6 @@ f"checksum {hashutil.hash_to_hex(_md5sum)} does not match.", ) - return None - def _binary_upload( self, request: Request, @@ -439,13 +437,10 @@ filehandler = request.FILES["file"] - precondition_status_response = self._check_preconditions_on( + self._check_preconditions_on( filehandler, headers.content_md5sum, content_length ) - if precondition_status_response: - return precondition_status_response - slug = headers.slug if check_slug_is_present and not slug: raise_missing_slug_error() @@ -575,12 +570,7 @@ if not filehandler: filehandler = data["application/x-tar"] - precondition_status_response = self._check_preconditions_on( - filehandler, headers.content_md5sum - ) - - if precondition_status_response: - return precondition_status_response + self._check_preconditions_on(filehandler, headers.content_md5sum) try: raw_metadata, metadata = self._read_metadata(data["application/atom+xml"]) @@ -941,8 +931,7 @@ def _basic_not_allowed_method(self, request: Request, method: str): raise DepositError( - METHOD_NOT_ALLOWED, - f"{method} method is not supported on this endpoint", + METHOD_NOT_ALLOWED, f"{method} method is not supported on this endpoint", ) def get(