theforeman / theforeman-rel-eng

Release engineering scripts
0 stars 15 forks source link

clean up after ContentTooShortError #363

Closed evgeni closed 3 months ago

evgeni commented 3 months ago

sometimes urlretrieve will not get the whole file and raise a ContentTooShortError. it will not delete the partially downloaded file in this case, which in a later run will cause issues as "the file is already there" but "it's not a valid RPM file".

instead, catch the ContentTooShortError and try to delete the file

evgeni commented 3 months ago

I did read https://github.com/python/cpython/blob/main/Lib/urllib/request.py before opening this PR, and from the code itself: none. Obviously, any line could itself raise something w/o an explicit raise, but oh well…