Fix #187 set a 5 second timer to save the config file after a config

value has been changed.
This commit is contained in:
Andrew Resch
2008-09-25 02:11:02 +00:00
parent 8660209d28
commit 1cf863a022
2 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,9 @@
Deluge 1.0.0 - "Sharks are bulletproof" (21 September 2008)
Deluge 1.0.1 (In Development)
Misc:
* Fix #187 set a 5 second timer to save the config file after a config value
has been changed.
Deluge 1.0.0 - "Sharks Are Bulletproof" (21 September 2008)
Core:
* Include GeoIP database for country look-ups
* Fix upgrading from 0.5.x state where torrents would have no trackers

View File

@ -65,6 +65,10 @@ class Config:
# Save
self.save()
# This will get set with a gobject.timeout_add whenever a config option
# is set.
self.save_timer = None
def __del__(self):
self.save()
@ -99,6 +103,7 @@ class Config:
pkl_file.close()
if filedump == self.config:
# The config has not changed so lets just return
self.save_timer = None
return
except (EOFError, IOError):
log.warning("IOError: Unable to open file: '%s'", filename)
@ -110,6 +115,8 @@ class Config:
except IOError:
log.warning("IOError: Unable to save file '%s'", filename)
self.save_timer = None
def set(self, key, value):
"""Set the 'key' with 'value'."""
# Sets the "key" with "value" in the config dict
@ -128,6 +135,11 @@ class Config:
except:
pass
# We set the save_timer for 5 seconds if not already set
log.debug("save_timer: %s", self.save_timer)
if not self.save_timer:
self.save_timer = gobject.timeout_add(5000, self.save)
def get(self, key):
"""Get the value of 'key'. If it is an invalid key then get() will
return None."""