merge #4403: [downloader:http] close connection when file already exists
This commit is contained in:
@@ -225,6 +225,14 @@ class HttpDownloader(DownloaderBase):
|
|||||||
pathfmt.build_path()
|
pathfmt.build_path()
|
||||||
if pathfmt.exists():
|
if pathfmt.exists():
|
||||||
pathfmt.temppath = ""
|
pathfmt.temppath = ""
|
||||||
|
# release the connection back to pool by explicitly
|
||||||
|
# calling .close()
|
||||||
|
# see https://requests.readthedocs.io/en/latest/user
|
||||||
|
# /advanced/#body-content-workflow
|
||||||
|
# when the image size is on the order of megabytes,
|
||||||
|
# re-establishing a TLS connection will typically be faster
|
||||||
|
# than consuming the whole response
|
||||||
|
response.close()
|
||||||
return True
|
return True
|
||||||
if self.part and metadata:
|
if self.part and metadata:
|
||||||
pathfmt.part_enable(self.partdir)
|
pathfmt.part_enable(self.partdir)
|
||||||
@@ -246,6 +254,7 @@ class HttpDownloader(DownloaderBase):
|
|||||||
if self._adjust_extension(pathfmt, file_header) and \
|
if self._adjust_extension(pathfmt, file_header) and \
|
||||||
pathfmt.exists():
|
pathfmt.exists():
|
||||||
pathfmt.temppath = ""
|
pathfmt.temppath = ""
|
||||||
|
response.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# set open mode
|
# set open mode
|
||||||
|
|||||||
Reference in New Issue
Block a user