diff options
author | Chase Sterling <chase.sterling@gmail.com> | 2010-09-13 02:20:06 -0400 |
---|---|---|
committer | Chase Sterling <chase.sterling@gmail.com> | 2010-09-13 02:22:18 -0400 |
commit | d898def9eca1a9f7c91cda3667c2879a477fc353 (patch) | |
tree | 91ad613df532c8f65ff3a5f2225926dbe999f181 | |
parent | 3e2f6c4060da019abcc5d99fcb5bd0bd0a999c14 (diff) | |
download | deluge-d898def9eca1a9f7c91cda3667c2879a477fc353.tar.gz deluge-d898def9eca1a9f7c91cda3667c2879a477fc353.tar.bz2 deluge-d898def9eca1a9f7c91cda3667c2879a477fc353.zip |
Fix bugs with unicode torrents in AutoAdd plugin.
-rw-r--r-- | deluge/plugins/autoadd/autoadd/core.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/deluge/plugins/autoadd/autoadd/core.py b/deluge/plugins/autoadd/autoadd/core.py index a1c0129f3..aa58d8f53 100644 --- a/deluge/plugins/autoadd/autoadd/core.py +++ b/deluge/plugins/autoadd/autoadd/core.py @@ -102,9 +102,11 @@ class Core(CorePluginBase): if self.core_cfg.config.get('autoadd_enable'): # Disable core autoadd self.core_cfg['autoadd_enable'] = False + self.core_cfg.save() # Check if core autoadd folder is already added in plugin for watchdir in self.watchdirs: if os.path.abspath(self.core_cfg['autoadd_location']) == watchdir['abspath']: + watchdir['enabled'] = True break else: # didn't find core watchdir, add it @@ -130,7 +132,7 @@ class Core(CorePluginBase): def set_options(self, watchdir_id, options): """Update the options for a watch folder.""" watchdir_id = str(watchdir_id) - options = self._clean_unicode(options) + options = self._make_unicode(options) CheckInput(watchdir_id in self.watchdirs , _("Watch folder does not exist.")) if options.has_key('path'): options['abspath'] = os.path.abspath(options['path']) @@ -194,7 +196,6 @@ class Core(CorePluginBase): if OPTIONS_AVAILABLE.get(option): if watchdir.get(option+'_toggle', True): opts[option] = value - opts = self._clean_unicode(opts) for filename in os.listdir(watchdir["abspath"]): if filename.split(".")[-1] == "torrent": try: @@ -276,6 +277,7 @@ class Core(CorePluginBase): @export def set_config(self, config): """Sets the config dictionary.""" + config = self._make_unicode(config) for key in config.keys(): self.config[key] = config[key] self.config.save() @@ -289,21 +291,19 @@ class Core(CorePluginBase): @export() def get_watchdirs(self): return self.watchdirs.keys() - - def _clean_unicode(self, options): + + def _make_unicode(self, options): opts = {} - for key, value in options.iteritems(): - if isinstance(key, unicode): - key = str(key) - if isinstance(value, unicode): - value = str(value) - opts[key] = value + for key in options: + if isinstance(options[key], str): + options[key] = unicode(options[key], "utf8") + opts[key] = options[key] return opts @export() def add(self, options={}): """Add a watch folder.""" - options = self._clean_unicode(options) + options = self._make_unicode(options) abswatchdir = os.path.abspath(options['path']) CheckInput(os.path.isdir(abswatchdir) , _("Path does not exist.")) CheckInput(os.access(abswatchdir, os.R_OK|os.W_OK), "You must have read and write access to watch folder.") |