Fix potential skipping of published posts if prior posts weren't published

Sat, 23 May 2009 21:15:19 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 23 May 2009 21:15:19 +0100
changeset 5
951de9625338
parent 4
cebf96c3b522
child 6
cf40d55f8122

Fix potential skipping of published posts if prior posts weren't published

build.lua file | annotate | diff | comparison | revisions
--- a/build.lua	Sat May 23 20:18:49 2009 +0100
+++ b/build.lua	Sat May 23 21:15:19 2009 +0100
@@ -117,7 +117,7 @@
 
 msg_info(" - - - ");
 
-local unpublished = 0;
+local unpublished, removed_posts = 0, {};
 for n, post in ipairs(posts) do
 	if post.content and (not post.layout or layouts[post.layout]) then
 		lfs.mkdir(output_dir..post.shorttitle);
@@ -144,7 +144,7 @@
 				-- Not published yet, hide it
 				--msg_info("Hiding unpublished post");
 				unpublished = unpublished + 1;
-				posts[n] = nil;
+				table.insert(removed_posts, n);
 			end
 		else
 			msg_error("Failed to write HTML: %s", err);
@@ -157,6 +157,12 @@
 	end
 end
 
+local removed = 0;
+for _, n in ipairs(removed_posts) do
+	table.remove(posts, n-removed);
+	removed = removed + 1;
+end
+
 -- Do main page
 local main_tpl = templates.init(layouts_dir.."/main.html");
 

mercurial