move the config_directory attribute to a property that gets lazily set
This commit is contained in:
parent
7aea3a290e
commit
2b4ca765fa
|
@ -35,10 +35,16 @@ class _ConfigManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
log.debug("ConfigManager started..")
|
log.debug("ConfigManager started..")
|
||||||
self.config_files = {}
|
self.config_files = {}
|
||||||
self.config_directory = deluge.common.get_default_config_dir()
|
self.__config_directory = None
|
||||||
# Set a 5 minute timer to call save()
|
# Set a 5 minute timer to call save()
|
||||||
gobject.timeout_add(300000, self.save)
|
gobject.timeout_add(300000, self.save)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config_directory(self):
|
||||||
|
if self.__config_directory is None:
|
||||||
|
self.__config_directory = deluge.common.get_default_config_dir()
|
||||||
|
return self.__config_directory
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
log.debug("ConfigManager stopping..")
|
log.debug("ConfigManager stopping..")
|
||||||
del self.config_files
|
del self.config_files
|
||||||
|
@ -55,7 +61,7 @@ class _ConfigManager:
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.warning("Unable to make config directory: %s", e)
|
log.warning("Unable to make config directory: %s", e)
|
||||||
|
|
||||||
self.config_directory = directory
|
self.__config_directory = directory
|
||||||
|
|
||||||
def get_config_dir(self):
|
def get_config_dir(self):
|
||||||
return self.config_directory
|
return self.config_directory
|
||||||
|
|
Loading…
Reference in New Issue