git » blitiri » commit 74a7143

Create the comments directory for an article if it doesn't exist

author Alberto Bertogli
2008-09-06 14:29:30 UTC
committer Alberto Bertogli
2008-09-06 14:51:30 UTC
parent b33059d59653fdea856cb61e8feb3b23370b6861

Create the comments directory for an article if it doesn't exist

It is needed when comments are enabled after the article was added,
otherwise the save() will fail.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

blitiri.cgi +5 -0

diff --git a/blitiri.cgi b/blitiri.cgi
index 0c48475..6ada91b 100755
--- a/blitiri.cgi
+++ b/blitiri.cgi
@@ -775,6 +775,11 @@ class Comment (object):
 class CommentDB (object):
 	def __init__(self, article):
 		self.path = os.path.join(comments_path, article.uuid)
+		# if comments were enabled after the article was added, we
+		# will need to create the directory
+		if not os.path.exists(self.path):
+			os.mkdir(self.path, 0755)
+
 		self.comments = []
 		self.load(article)