diff --git a/CHANGES.md b/CHANGES.md index c0415156..9f96b6fc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -226,6 +226,7 @@ * Change improve TvChaos item parsing and can use qualities instead of 'Unknown' * Change remove deprecated providers being saved to config * Change prevent a missing slash typo and correct develop typo after a network outage +* Change send download logfile as stream ### 0.11.16 (2016-10-16 17:30:00 UTC) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index bab1ebc9..c4c86926 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -5495,10 +5495,21 @@ class ErrorLogs(MainHandler): self.redirect('/errorlogs/') def downloadlog(self, *args, **kwargs): - self.set_header('Content-Type', 'text/plain') + logfile_name = logger.current_log_file() + self.set_header('Content-Type', 'application/octet-stream') + self.set_header('Content-Description', 'Logfile Download') + self.set_header('Content-Length', ek.ek(os.path.getsize, logfile_name)) self.set_header('Content-Disposition', 'attachment; filename=sickgear.log') - with open(logger.current_log_file(), 'r') as logfile: - return logfile.read() + with open(logfile_name, 'r') as logfile: + try: + while True: + data = logfile.read(4096) + if not data: + break + self.write(data) + self.finish() + except (StandardError, Exception): + return def viewlog(self, minLevel=logger.MESSAGE, maxLines=500):