diff --git a/CHANGES/8383.bugfix b/CHANGES/8383.bugfix new file mode 100644 index 00000000000..6c6549dbf24 --- /dev/null +++ b/CHANGES/8383.bugfix @@ -0,0 +1 @@ +Fixed a race condition during concurrent on-demand downloads where unlinking an already-moved temporary artifact raised FileNotFoundError and aborted client transfers. diff --git a/pulpcore/content/handler.py b/pulpcore/content/handler.py index 73ea2b2f4a8..301cf2a79c0 100644 --- a/pulpcore/content/handler.py +++ b/pulpcore/content/handler.py @@ -894,7 +894,11 @@ def _save_artifact(self, download_result, remote_artifact, request=None): # The file needs to be unlinked because it was not used to create an artifact. # The artifact must have already been saved while servicing another request for # the same artifact. - os.unlink(download_result.path) + try: + os.unlink(download_result.path) + except FileNotFoundError: + # Temp file may already be moved to storage before the IntegrityError + pass if content_artifact._state.adding: # This is the first time pull-through content was requested.