From e7a59b326f30caefc50895a2a0246a8a2d7dd9a6 Mon Sep 17 00:00:00 2001 From: miigotu <miigotu@gmail.com> Date: Sat, 26 Dec 2015 03:45:19 -0800 Subject: [PATCH] Remove cache/mako before starting tornado server, and after stopping it Fix a small bug where sickbeard.started might not have been set to false --- SickBeard.py | 27 ++++++++++++++------------- sickbeard/__init__.py | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/SickBeard.py b/SickBeard.py index 2ea7a99f4..93b5b140c 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -301,6 +301,14 @@ class SickRage(object): # Build from the DB to start with self.loadShowsFromDB() + if self.consoleLogging: + print "Starting up SickRage " + sickbeard.BRANCH + " from " + sickbeard.CONFIG_FILE + + # Clean up after update + if sickbeard.GIT_NEWVER: + shutil.rmtree(ek(os.path.join, sickbeard.CACHE_DIR, 'mako')) + sickbeard.GIT_NEWVER = False + if self.forcedPort: logger.log(u"Forcing web server to port " + str(self.forcedPort)) self.startPort = self.forcedPort @@ -341,19 +349,6 @@ class SickRage(object): self.webserver = SRWebServer(self.web_options) self.webserver.start() - if self.consoleLogging: - print "Starting up SickRage " + sickbeard.BRANCH + " from " + sickbeard.CONFIG_FILE - - # Clean up after update - if sickbeard.GIT_NEWVER: - toclean = ek(os.path.join, sickbeard.CACHE_DIR, 'mako') - for root, dirs, files in ek(os.walk, toclean, topdown=False): - for name in files: - ek(os.remove, ek(os.path.join, root, name)) - for name in dirs: - ek(os.rmdir, ek(os.path.join, root, name)) - sickbeard.GIT_NEWVER = False - # Fire up all our threads sickbeard.start() @@ -503,6 +498,12 @@ class SickRage(object): except Exception: pass + try: + logger.log(u"Halt: Trying to remove the cache/mako directory") + shutil.rmtree(ek(os.path.join, sickbeard.CACHE_DIR, 'mako')) + except Exception: + logger.log(u"Halt: Unable to remove the cache/mako directory!", logger.WARNING) + # if run as daemon delete the pidfile if self.runAsDaemon and self.CREATEPID: self.remove_pid_file(self.PIDFILE) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 6ebb0f92b..e6043c7bb 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -1576,7 +1576,7 @@ def halt(): pass __INITIALIZED__ = False - started = False + started = False def sig_handler(signum=None, frame=None): -- GitLab