cacheability improvements
authordavyd <davyd>
Mon, 15 Mar 2004 02:56:52 +0000 (02:56 +0000)
committerdavyd <davyd>
Mon, 15 Mar 2004 02:56:52 +0000 (02:56 +0000)
CacheHandler.py
update-planet

index 3463d71..7106279 100644 (file)
@@ -36,3 +36,5 @@ class CacheObject:
        def __init__(self):
                self.etag       = None
                self.date       = None
+       def __eq__(self, other):
+               return self.etag == other.etag and self.date == other.date
index 86fc4a8..09c40b0 100755 (executable)
@@ -28,6 +28,7 @@ for feed in open('feedlist').readlines():
                        sys.stderr.write('DEBUG: update-planet: something went wrong retrieving feed\n')
 
 # step 2: process each feed
+tainted        = False
 blogs  = []
 for feed in feeds:
        # XMLParse2 takes two paramaters, a URL and a CacheObject
@@ -36,11 +37,20 @@ for feed in feeds:
                blog.blogTitle  = feed[0]
                blog.feedURL    = feed[1]
                blogs.append(blog)
+               # check the old copy of the cache, vs the new copy
+               if feed[2].cache == blog.cache:
+                       pass
+               else:
+                       tainted = True
                # write the cache back down to disk
                cache.storeBlog(blog)
        else:
                pass
 
+if not tainted:
+       sys.stderr.write('PlanetUCC: no objects have changed in the cache, not updating\n')
+       sys.exit(1)
+
 # step 3: sift the feeds
 xmlwriter      = XMLWriter.XMLWriter(blogs)
 

UCC git Repository :: git.ucc.asn.au