#15: Allow for caching to be disabled, delete database when cache is disabled, remove unneeded conditional logic from method calls and move into methods themselves.

This commit is contained in:
Bill Dengler 2015-05-09 23:12:17 -04:00
parent f394701789
commit a5198b881e
2 changed files with 10 additions and 4 deletions

View File

@ -531,8 +531,7 @@ class Controller(object):
if hasattr(session_.sessions[item], "timelinesStream"): session_.sessions[item].timelinesStream.disconnect()
session_.sessions[item].sound.cleaner.cancel()
log.debug("Shelving database for " + session_.sessions[item].session_id)
if session_.sessions[item].settings["general"]["persistant_session"] == True:
session_.sessions[item].shelve()
session_.sessions[item].shelve()
if system == "Windows":
self.systrayIcon.RemoveIcon()

View File

@ -113,8 +113,7 @@ class Session(object):
log.debug("Creating config file %s" % (file_,))
self.settings = config_utils.load_config(paths.config_path(file_), paths.app_path("Conf.defaults"))
self.init_sound()
if self.settings["general"]["persist_size"] != 0:
self.deshelve()
self.deshelve()
# except:
# log.exception("The session configuration has failed.")
# self.settings = None
@ -370,6 +369,10 @@ class Session(object):
def shelve(self):
"Shelve the database to allow for persistance."
shelfname=paths.config_path(str(self.session_id)+".db")
if self.settings["general"]["persist_size"] == 0:
if os.path.exists(shelfname)
os.remove(shelfname)
return
try:
if not os.path.exists(shelfname):
output.speak("Generating database, this might take a while.",True)
@ -391,6 +394,10 @@ class Session(object):
def deshelve(self):
"Import a shelved database."
shelfname=paths.config_path(str(self.session_id)+".db")
if self.settings["general"]["persist_size"] == 0:
if os.path.exists(shelfname)
os.remove(shelfname)
return
try:
shelf=shelve.open(paths.config_path(shelfname),'c')
for key,value in shelf.items():