File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1313#
1414# You should have received a copy of the GNU General Public License
1515# along with this program. If not, see <https://www.gnu.org/licenses/>.
16-
16+ import logging
1717from http .client import HTTPResponse
1818
1919from PyQt5 .QtCore import pyqtSignal
@@ -34,8 +34,19 @@ def chunked_download(
3434 :param size: the size of the download, in bytes; used for progress
3535 :param progress_signal: the PyQt signal with which to emit download progress
3636 """
37+ if progress_signal is None :
38+ logging .warning (f"Progress signal is None." )
39+
3740 if not size :
38- size = 10 ** 6 * 44
41+ length = response .headers .get ("content-length" )
42+ if length :
43+ length = int (length )
44+ logging .info (f"Download size is { length / 1024 ** 2 :.1f} MB." )
45+
46+ size = length
47+ else :
48+ size = 10 ** 6 * 44
49+ logging .warning (f"Guessing download size." )
3950
4051 with open (filename , "wb" ) as f :
4152 bytes_downloaded = 0
You can’t perform that action at this time.
0 commit comments