Change send download logfile as stream.

This commit is contained in:
Prinz23 2016-11-07 15:39:55 +01:00 committed by JackDandy
parent 89a2405c99
commit 4001944928
2 changed files with 15 additions and 3 deletions

View file

@ -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)

View file

@ -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):