Make DownloadItem._autoclose private
This commit is contained in:
parent
b00c889dd1
commit
de1e3a7a54
@ -256,8 +256,6 @@ class AbstractDownloadItem(QObject):
|
|||||||
index: The index of the download in the view.
|
index: The index of the download in the view.
|
||||||
successful: Whether the download has completed successfully.
|
successful: Whether the download has completed successfully.
|
||||||
error_msg: The current error message, or None
|
error_msg: The current error message, or None
|
||||||
autoclose: Whether to close the associated file if the download is
|
|
||||||
done.
|
|
||||||
fileobj: The file object to download the file to.
|
fileobj: The file object to download the file to.
|
||||||
raw_headers: The headers sent by the server.
|
raw_headers: The headers sent by the server.
|
||||||
_filename: The filename of the download.
|
_filename: The filename of the download.
|
||||||
@ -288,7 +286,6 @@ class AbstractDownloadItem(QObject):
|
|||||||
self.basename = '???'
|
self.basename = '???'
|
||||||
self.successful = False
|
self.successful = False
|
||||||
|
|
||||||
self.autoclose = UnsupportedAttribute()
|
|
||||||
self.fileobj = UnsupportedAttribute()
|
self.fileobj = UnsupportedAttribute()
|
||||||
self.raw_headers = UnsupportedAttribute()
|
self.raw_headers = UnsupportedAttribute()
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ class DownloadItem(downloads.AbstractDownloadItem):
|
|||||||
periodically.
|
periodically.
|
||||||
_manager: The DownloadManager which started this download
|
_manager: The DownloadManager which started this download
|
||||||
_reply: The QNetworkReply associated with this download.
|
_reply: The QNetworkReply associated with this download.
|
||||||
|
_autoclose: Whether to close the associated file when the download is
|
||||||
|
done.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_MAX_REDIRECTS = 10
|
_MAX_REDIRECTS = 10
|
||||||
@ -77,10 +79,10 @@ class DownloadItem(downloads.AbstractDownloadItem):
|
|||||||
reply: The QNetworkReply to download.
|
reply: The QNetworkReply to download.
|
||||||
"""
|
"""
|
||||||
super().__init__(parent=manager)
|
super().__init__(parent=manager)
|
||||||
self.autoclose = True
|
|
||||||
self.fileobj = None
|
self.fileobj = None
|
||||||
self.raw_headers = {}
|
self.raw_headers = {}
|
||||||
|
|
||||||
|
self._autoclose = True
|
||||||
self._manager = manager
|
self._manager = manager
|
||||||
self._retry_info = None
|
self._retry_info = None
|
||||||
self._reply = None
|
self._reply = None
|
||||||
@ -196,7 +198,7 @@ class DownloadItem(downloads.AbstractDownloadItem):
|
|||||||
raise ValueError("fileobj was already set! Old: {}, new: "
|
raise ValueError("fileobj was already set! Old: {}, new: "
|
||||||
"{}".format(self.fileobj, fileobj))
|
"{}".format(self.fileobj, fileobj))
|
||||||
self.fileobj = fileobj
|
self.fileobj = fileobj
|
||||||
self.autoclose = autoclose
|
self._autoclose = autoclose
|
||||||
try:
|
try:
|
||||||
self._read_timer.stop()
|
self._read_timer.stop()
|
||||||
log.downloads.debug("buffer: {} bytes".format(self._buffer.tell()))
|
log.downloads.debug("buffer: {} bytes".format(self._buffer.tell()))
|
||||||
@ -223,7 +225,7 @@ class DownloadItem(downloads.AbstractDownloadItem):
|
|||||||
log.downloads.debug("Finishing download...")
|
log.downloads.debug("Finishing download...")
|
||||||
if self._reply.isOpen():
|
if self._reply.isOpen():
|
||||||
self.fileobj.write(self._reply.readAll())
|
self.fileobj.write(self._reply.readAll())
|
||||||
if self.autoclose:
|
if self._autoclose:
|
||||||
self.fileobj.close()
|
self.fileobj.close()
|
||||||
self.successful = self._reply.error() == QNetworkReply.NoError
|
self.successful = self._reply.error() == QNetworkReply.NoError
|
||||||
self._reply.close()
|
self._reply.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user