import: Handle small files#42150
Conversation
To call into pull_job_write_(un)compressed and pull_job_open_disk from pull_job_curl_on_finished it has to be defined after them. This is in preparation for a bug fix for small files where we need to leave the compression analysis state to finish the download successfully.
| return j->content_length; | ||
| } | ||
|
|
||
| static int pull_job_write_uncompressed(const void *p, size_t sz, void *userdata) { |
There was a problem hiding this comment.
FYI: This and the other two functions are just moved. It's a separate commit.
The only new function is pull_job_begin_running.
Claude review of PR #42150 (5f299e5)Nits
|
| if (j->state == PULL_JOB_ANALYZING) { | ||
| /* When curl finished the download while we were still looking for a compression magic | ||
| * header the content isn't compressed but should be written out as is. */ | ||
| assert(result == CURLE_OK); |
There was a problem hiding this comment.
Claude: nit: assert(result == CURLE_OK) is always true here because the result != CURLE_OK case returns early at line 358. The assert is redundant, though it does document the invariant.
There was a problem hiding this comment.
That's pretty much the point of an assert
There was a problem hiding this comment.
This could be extended to also cover the http code check that was done before but that would require capturing this in a variable that does not exist yet and I think it's already good enough to indicate that the download was successful here from the checks above.
When systemd-pull encountered a file shorter than the compression magic headers it looks for, then it would complete the download in the analysis state and fail. When we are still in the analysis state and the download is done, we know there is no compression and we should leave the analysis state and continue writing out to disk as usual.
When systemd-pull encountered a file shorter than the compression magic
headers it looks for, then it would complete the download in the
analysis state and fail.
When we are still in the analysis state and the download is done, we
know there is no compression and we should leave the analysis state and
continue writing out to disk as usual.