aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xzzcxz.cgi8
1 files changed, 7 insertions, 1 deletions
diff --git a/zzcxz.cgi b/zzcxz.cgi
index ea9cab0..d5a62b6 100755
--- a/zzcxz.cgi
+++ b/zzcxz.cgi
@@ -254,12 +254,18 @@ local function new_action(page, action, result)
return directives.redirect
end
+::generate_name::
local new_name = {}
for i=1,5 do
table.insert(new_name, string.char(string.byte 'a' + math.random(0,25)))
end
new_name = table.concat(new_name)
- assert(not io.open('content/'..new_name, 'r'), "page already exists!")
+
+ local exists = io.open('content/'..new_name, 'r')
+ if exists then
+ exists:close()
+ goto generate_name
+ end
local new = assert(io.open('content/'..new_name, 'w'))