From 685e20fbf10a93fd688f8b9187088bf692e8c171 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 18 Sep 2007 06:26:22 +0000 Subject: [PATCH] Only write a config file to disk if there is a change in the configuration. --- deluge/config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/deluge/config.py b/deluge/config.py index 7cb0e6487..69845d9bc 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -84,6 +84,20 @@ class Config: # Saves the config dictionary if filename is None: filename = self.config_file + # Check to see if the current config differs from the one on disk + # We will only write a new config file if there is a difference + try: + log.debug("Opening pickled file for comparison..") + pkl_file = open(filename, "rb") + filedump = pickle.load(pkl_file) + pkl_file.close() + if filedump == self.config: + # The config has not changed so lets just return + log.debug("Not writing config file due to no changes..") + return + except IOError: + log.warning("IOError: Unable to open file: '%s'", filename) + try: log.debug("Opening pickled file for save..") pkl_file = open(filename, "wb")