1
0
Fork 0

[networking] Ensure underlying file object is closed when fully read (#14935)

Fixes https://github.com/yt-dlp/yt-dlp/issues/14891

Authored by: coletdjnz
This commit is contained in:
coletdjnz 2025-11-08 18:30:43 +13:00 committed by GitHub
commit 5767fb4ab1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 124 additions and 16 deletions

View file

@ -96,7 +96,10 @@ class CurlCFFIResponseAdapter(Response):
def read(self, amt=None):
try:
return self.fp.read(amt)
res = self.fp.read(amt)
if self.fp.closed:
self.close()
return res
except curl_cffi.requests.errors.RequestsError as e:
if e.code == CurlECode.PARTIAL_FILE:
content_length = e.response and int_or_none(e.response.headers.get('Content-Length'))