diff --git a/dynastie/generators/generator.py b/dynastie/generators/generator.py
index 428c495..5dea852 100755
--- a/dynastie/generators/generator.py
+++ b/dynastie/generators/generator.py
@@ -90,19 +90,35 @@ class DynastieGenerator:
return int(res)
def writeIfNotTheSame(self, filename, node):
+ from dynastie.models import FileOutputCache
+
writer = StrictUTF8Writer()
node.writexml(writer)
content = writer.getvalue().encode('utf-8')
- if os.path.exists(filename):
- src_md5 = hashlib.md5()
- f = open(filename,'rb')
- src_md5.update(f.read())
- f.close()
- dst_md5 = hashlib.md5()
- dst_md5.update(content)
+ dst_md5 = hashlib.md5()
+ dst_md5.update(content)
- if src_md5.digest() == dst_md5.digest():
+ cache_objs = FileOutputCache.objects.filter(name=filename)
+ if cache_objs.count() == 0:
+ cache_obj = None
+ else:
+ cache_obj = cache_objs[0]
+
+ if not cache_obj is None or os.path.exists(filename):
+ if cache_obj is None:
+ src_md5 = hashlib.md5()
+ f = open(filename,'rb')
+ src_md5.update(f.read())
+ f.close()
+ src_md5 = src_md5.hexdigest()
+ else:
+ src_md5 = cache_obj.hash
+
+ if src_md5 == dst_md5.hexdigest():
+ if cache_obj is None:
+ cache_obj = FileOutputCache(name=filename, hash=src_md5)
+ cache_obj.save()
filename = filename + '.gz'
if not os.path.exists(filename):
f = gzip.open(filename, 'wb')
@@ -111,6 +127,11 @@ class DynastieGenerator:
return
os.unlink(filename)
+ if cache_obj is None:
+ cache_obj = FileOutputCache(name=filename, hash=dst_md5.hexdigest())
+ else:
+ cache_obj.hash = dst_md5.hexdigest()
+
self.addReport('Write (and compress) ' + filename)
f = open(filename,'wb')
f.write(content)
@@ -122,6 +143,8 @@ class DynastieGenerator:
f.write(content)
f.close()
+ cache_obj.save()
+
self.somethingWrote = True
def createLinkElem(self, dom, path, title):
diff --git a/dynastie/models.py b/dynastie/models.py
index 5d7d5b4..75d3830 100755
--- a/dynastie/models.py
+++ b/dynastie/models.py
@@ -305,38 +305,20 @@ class Post(models.Model):
self.tags.remove(t)
def createPost(self, content, tags):
- b = self.blog
- output = b.src_path
+ output = self.blog.src_path
if not os.path.exists(output + '/_post'):
os.mkdir(output + '/_post')
filename = output + '/_post/' + str(self.pk)
content = unicode(content)
content = content.encode('utf-8')
- modif = True
- if os.path.exists(filename):
- f = open(filename, 'rb')
- src_md5 = hashlib.md5()
- src_md5.update(f.read())
- f.close()
-
- dst_md5 = hashlib.md5()
- dst_md5.update(content)
-
- if src_md5.digest() == dst_md5.digest():
- modif = False
- else:
- os.unlink(filename)
-
- if modif:
- f = open(filename, 'wb')
- f.write(content)
- f.close()
- self.modification_date=datetime.now()
+ f = open(filename, 'wb')
+ f.write(content)
+ f.close()
+ self.modification_date=datetime.now()
self.manageTags(tags)
- self.save()
def remove(self):
b = self.blog
@@ -432,6 +414,10 @@ class Comment(models.Model):
def _remove_br(self):
self.the_comment = self.the_comment.replace('
', '\n')
+class FileOutputCache(models.Model):
+ name = models.CharField(max_length=512)
+ hash = models.CharField(max_length=512)
+
@receiver(post_init, sender=Blog)
def init_blog_signal(sender, **kwargs):
kwargs['instance'].create_paths()
diff --git a/dynastie/sites/blog.soutade.fr/_ljdc.xml b/dynastie/sites/blog.soutade.fr/_ljdc.xml
index 699dad3..a09b183 100644
--- a/dynastie/sites/blog.soutade.fr/_ljdc.xml
+++ b/dynastie/sites/blog.soutade.fr/_ljdc.xml
@@ -1,5 +1,23 @@
+
+ 87094581962
+ http://thecodinglove.com/post/87094581962/when-caffeine-is-no-longer-effective
+ when caffeine is no longer effective
+
http://i.imgur.com/ocjPFJL.gif
+
+
+ 85721632915
+ http://lesjoiesducode.fr/post/85721632915/quand-je-suggere-lusage-de-nouvelles-technos
+ quand je suggère l'usage de nouvelles technos
+
http://i.imgur.com/BezORLq.gif
+
+
+ 85709017865
+ http://lesjoiesducode.fr/post/85709017865/quand-un-collegue-me-refile-un-ticket-facile-a
+ quand un collègue me refile un ticket "facile à traiter"
+
http://ljdchost.com/XyeioZc.gif
+
85704348740
http://lesjoiesducode.fr/post/85704348740/quand-le-client-reclame-une-feature-hors-cahier-des