make wopr work again

This commit is contained in:
Neale Pickett 2012-05-22 12:54:51 -06:00
parent 4052dae78b
commit 56a9f8a0ce
1 changed files with 4 additions and 9 deletions

View File

@ -1,6 +1,4 @@
#! /usr/bin/lua #! /bin/env lua
require("lfs")
BASEDIR = "/var/tmp/wopr" BASEDIR = "/var/tmp/wopr"
POST_MAX = 512 POST_MAX = 512
@ -128,7 +126,7 @@ end
-- --
function get(key, ...) function get(key, ...)
local fn = string.format("%s/%s", dirname, key) local fn = string.format("%s.%s", dirname, key)
local f = io.open(fn) local f = io.open(fn)
if (not f) then if (not f) then
return arg[1] return arg[1]
@ -140,12 +138,9 @@ function get(key, ...)
end end
function set(key, ...) function set(key, ...)
local fn = string.format("%s/%s", dirname, key) local fn = string.format("%s.%s", dirname, key)
local f local f
-- Lazy mkdir to save a few inodes
lfs.mkdir(dirname)
f = io.open(fn, "w") f = io.open(fn, "w")
if not f then if not f then
error("Unable to write " .. fn) error("Unable to write " .. fn)
@ -155,7 +150,7 @@ function set(key, ...)
end end
function del(key) function del(key)
local fn = string.format("%s/%s", dirname, key) local fn = string.format("%s.%s", dirname, key)
os.remove(fn) os.remove(fn)
end end