fix Thumbnail.stale/File.older_than behaviour
authorTero Marttila <terom@fixme.fi>
Thu, 11 Jun 2009 21:50:48 +0300
changeset 95 3b00bd676fc9
parent 94 676c1d201cfe
child 96 d9cf1e272e90
fix Thumbnail.stale/File.older_than behaviour
degal/filesystem.py
degal/thumbnail.py
--- a/degal/filesystem.py	Thu Jun 11 21:46:20 2009 +0300
+++ b/degal/filesystem.py	Thu Jun 11 21:50:48 2009 +0300
@@ -553,14 +553,7 @@
         """
         
         # mirror
-        ret = file.newer_than(self)
-        
-        # retain meaning of `None`, but invert True/False
-        if ret is None :
-            return ret
-
-        else :
-            return not ret
+        return file.newer_than(self)
 
 class Directory (Node) :
     """
--- a/degal/thumbnail.py	Thu Jun 11 21:46:20 2009 +0300
+++ b/degal/thumbnail.py	Thu Jun 11 21:50:48 2009 +0300
@@ -19,9 +19,8 @@
             `size` determines the target resolution of the output thumbnail.
         """
 
-        # our file path
-        # XXX: this should be the binary fsname, not name
-        super(Thumbnail, self).__init__(subdir.subnode(image.name))
+        # our file path, image name inside of the given subdir
+        super(Thumbnail, self).__init__(subdir, image.fsname)
 
         # store
         self.image = image
@@ -32,7 +31,13 @@
             Tests if this thumbnail is stale
         """
         
-        return self.older_than(self.image)
+        if self.image.older_than(self) :
+            # both exist and this is newer
+            return False
+        
+        else :
+            # this thumb doesn't exist or is older
+            return True
 
     def update (self) :
         """
@@ -47,4 +52,4 @@
 
         # and write out
         thumb.save(self.path)
-
+