From de1e3a7a54b1841faf0296599c28fbcfa62e666b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 8 Nov 2016 20:35:07 +0100 Subject: [PATCH] Make DownloadItem._autoclose private --- qutebrowser/browser/downloads.py | 3 --- qutebrowser/browser/qtnetworkdownloads.py | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index a4018aa04..be4d3285b 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -256,8 +256,6 @@ class AbstractDownloadItem(QObject): index: The index of the download in the view. successful: Whether the download has completed successfully. 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. raw_headers: The headers sent by the server. _filename: The filename of the download. @@ -288,7 +286,6 @@ class AbstractDownloadItem(QObject): self.basename = '???' self.successful = False - self.autoclose = UnsupportedAttribute() self.fileobj = UnsupportedAttribute() self.raw_headers = UnsupportedAttribute() diff --git a/qutebrowser/browser/qtnetworkdownloads.py b/qutebrowser/browser/qtnetworkdownloads.py index fd62c8ffc..b9aaeea8c 100644 --- a/qutebrowser/browser/qtnetworkdownloads.py +++ b/qutebrowser/browser/qtnetworkdownloads.py @@ -66,6 +66,8 @@ class DownloadItem(downloads.AbstractDownloadItem): periodically. _manager: The DownloadManager which started this download _reply: The QNetworkReply associated with this download. + _autoclose: Whether to close the associated file when the download is + done. """ _MAX_REDIRECTS = 10 @@ -77,10 +79,10 @@ class DownloadItem(downloads.AbstractDownloadItem): reply: The QNetworkReply to download. """ super().__init__(parent=manager) - self.autoclose = True self.fileobj = None self.raw_headers = {} + self._autoclose = True self._manager = manager self._retry_info = None self._reply = None @@ -196,7 +198,7 @@ class DownloadItem(downloads.AbstractDownloadItem): raise ValueError("fileobj was already set! Old: {}, new: " "{}".format(self.fileobj, fileobj)) self.fileobj = fileobj - self.autoclose = autoclose + self._autoclose = autoclose try: self._read_timer.stop() log.downloads.debug("buffer: {} bytes".format(self._buffer.tell())) @@ -223,7 +225,7 @@ class DownloadItem(downloads.AbstractDownloadItem): log.downloads.debug("Finishing download...") if self._reply.isOpen(): self.fileobj.write(self._reply.readAll()) - if self.autoclose: + if self._autoclose: self.fileobj.close() self.successful = self._reply.error() == QNetworkReply.NoError self._reply.close()