Repository navigation
Remove a rejected download instead of keeping it as the archive - #12
Open
nu11waredev wants to merge 1 commit into
Open
nu11waredev wants to merge 1 commit into
nu11waredev wants to merge 1 commit into
Conversation
When Apple redirects a download to its unauthorized page, both downloaders have already saved that page at the archive's path. The error is reported, but the next run finds the file and uses it as the archive (XcodesOrg/xcodes#484). Remove it when the download is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nu11waredev
marked this pull request as ready for review
December 3, 2026 03:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs XcodesOrg/xcodes#484.
Problem
When Apple redirects an Xcode or runtime download to
developer.apple.com/unauthorized/, the unauthorized error is reported, but the page has already been saved at the archive's path. The next run finds that file and uses it as the archive:xcodes downloadprints "Found existing archive" and moves the page to Downloads, as in the report.Cause
downloadTask(with:to:resumingWith:)moves the response body to the save location, thenArchiveDownloadServicevalidates the response and throws, leaving the file in place.--outand exits 0.Aria2DownloadServicereturns the unauthorized error from its success handler, again leaving the file.Fix
Remove the saved file when the download is rejected, in both paths. The fix is here rather than in the CLI (as in the closed xcodes#487) because the CLI and Xcodes.app share these services.
Testing
testArchiveDownloadServiceURLSessionRemovesRejectedDownload: an unauthorized response from the URLSession download removes the saved file.testAria2DownloadServiceRemovesRejectedDownload: a stand-in aria2c script writes a page to--outand logs the redirect; the file is gone afterwards.mainand pass with the fix.swift test: 202 tests, 0 failures.A plain 403 or 404 without the redirect still passes
validateDeveloperDownloadResponse, since it only checks the URL's path. That's a separate change to the validator.