mirror of
https://github.com/mt-mods/mail.git
synced 2025-07-04 05:37:00 -04:00
separated from webmail mod
This commit is contained in:
commit
ca88374fbd
19 changed files with 941 additions and 0 deletions
24
migrate.lua
Normal file
24
migrate.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
-- 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) do
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue