Skip to content

Commit

Permalink
savefile.lua was broken
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Ritzl committed Nov 25, 2016
1 parent 43bcef5 commit 7bec11c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ludobits/m/savefile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ function M.open(filename)
--- Save table to the file
-- @param t The table to save
-- @return success
-- @return error_message
function instance.save(t)
assert(t and type(t) == "table", "You must provide a table to save")
sys.save(tmpfile, t)
local tmpname = os.tmpname()
local success = sys.save(tmpname, t)
if not success then
return false, "Unable to save file"
end
os.remove(path)
return os.rename(tmpname, path)
end

return instance
Expand Down

0 comments on commit 7bec11c

Please sign in to comment.