Author: johnnyg

Revision: 5444

Log:
        Added check to see if blocklist should be downloaded when load on start 
is enabled.
Updated function names in gtkui.

Diff:
Modified: trunk/deluge/plugins/blocklist/blocklist/core.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/core.py    2009-07-04 16:49:18 UTC 
(rev 5443)
+++ trunk/deluge/plugins/blocklist/blocklist/core.py    2009-07-04 17:05:50 UTC 
(rev 5444)
@@ -84,10 +84,17 @@
 
         self.config = deluge.configmanager.ConfigManager("blocklist.conf", 
DEFAULT_PREFS)
         if self.config["load_on_start"]:
-            # TODO: Check if been more than check_after_days
-            self.use_cache = True
-            d = self.import_list()
-            d.addCallbacks(self.on_import_complete, self.on_import_error)
+            if self.config["last_update"]:
+                now = datetime.datetime.now()
+                last_update = 
datetime.datetime.strptime(self.config["last_update"],
+                                                            "%a, %d %b %Y 
%H:%M:%S GMT")
+                check_period = 
datetime.timedelta(days=self.config["check_after_days"])
+            if not self.config["last_update"] or last_update + check_period >= 
now:
+                d = self.check_import()
+            else:
+                self.use_cache = True
+                d = self.import_list()
+                d.addCallbacks(self.on_import_complete, self.on_import_error)
 
         # This function is called every 'check_after_days' days, to download
         # and import a new list if needed.
@@ -175,10 +182,10 @@
         import socket
         socket.setdefaulttimeout(self.config["timeout"])
 
-        headers = {}
         if not url:
             url = self.config["url"]
 
+        headers = {}
         if self.config["last_update"] and not self.force_download:
             headers['If-Modified-Since'] = self.config["last_update"]
 

Modified: trunk/deluge/plugins/blocklist/blocklist/gtkui.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/gtkui.py   2009-07-04 16:49:18 UTC 
(rev 5443)
+++ trunk/deluge/plugins/blocklist/blocklist/gtkui.py   2009-07-04 17:05:50 UTC 
(rev 5444)
@@ -158,11 +158,11 @@
 
     def _on_button_check_download_clicked(self, widget):
         self._on_apply_prefs()
-        client.blocklist.import_list(False)
+        client.blocklist.check_import()
 
     def _on_button_force_download_clicked(self, widget):
         self._on_apply_prefs()
-        client.blocklist.import_list(True)
+        client.blocklist.check_import(force=True)
 
     def _on_status_item_clicked(self, widget, event):
         component.get("Preferences").show("Blocklist")



--~--~---------~--~----~------------~-------~--~----~
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