Module: deluge
Branch: 1.3-stable
Commit: d898def9eca1a9f7c91cda3667c2879a477fc353

Author: Chase Sterling <[email protected]>
Date:   Mon Sep 13 02:20:06 2010 -0400

Fix bugs with unicode torrents in AutoAdd plugin.

---

 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 a1c0129..aa58d8f 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.")

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to