mail/migrate.lua
2019-02-27 08:20:09 +01:00

24 lines
602 B
Lua

-- migrate from mail.db to player-file-based mailbox
mail.migrate = function()
local file = io.open(minetest.get_worldpath().."/mail.db", "r")
if file then
print("[mail] migrating to new per-player storage")
minetest.mkdir(mail.maildir)
local data = file:read("*a")
local oldmails = minetest.deserialize(data)
file:close()
for name, oldmessages in pairs(oldmails)
mail.setMessages(name, oldmessages)
end
-- rename file
print("[mail] migration done, renaming old mail.db")
os.rename(minetest.get_worldpath().."/mail.db", minetest.get_worldpath().."/mail.db.old")
end
end