forked from nalc/areas
Don't overwrite area file if serialization fails
This commit is contained in:
parent
72d26dad25
commit
a8e5b90aeb
|
@ -5,11 +5,16 @@ end
|
|||
|
||||
-- Save the areas table to a file
|
||||
function areas:save()
|
||||
local datastr = minetest.serialize(self.areas)
|
||||
if not datastr then
|
||||
minetest.log("error", "[areas] Failed to serialize area data!")
|
||||
return
|
||||
end
|
||||
local file, err = io.open(self.filename, "w")
|
||||
if err then
|
||||
return err
|
||||
end
|
||||
file:write(minetest.serialize(self.areas))
|
||||
file:write(datastr)
|
||||
file:close()
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user