From a5caecf96e7f92d07daa771722f361d299b00151 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Wed, 29 Mar 2023 07:54:14 +0200 Subject: [PATCH] internalize old mail-paths to migration module --- init.lua | 4 ---- migrate.lua | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 452c8f2..569df95 100644 --- a/init.lua +++ b/init.lua @@ -2,10 +2,6 @@ mail = { -- version version = 3, - -- mail directory - maildir = minetest.get_worldpath().."/mails", - contactsdir = minetest.get_worldpath().."/mails/contacts", - -- mod storage storage = minetest.get_mod_storage(), diff --git a/migrate.lua b/migrate.lua index 0623b97..5fe0838 100644 --- a/migrate.lua +++ b/migrate.lua @@ -46,7 +46,8 @@ end -- migrate from v2 to v3 database local function migrate_v2_to_v3() - minetest.mkdir(mail.maildir) -- if necessary (eg. first login) + local maildir = minetest.get_worldpath().."/mails" + minetest.mkdir(maildir) -- if necessary (eg. first login) print("[mail] Migration from v2 to v3 database") -- defer execution until auth-handler ready (first server-step) @@ -54,13 +55,13 @@ local function migrate_v2_to_v3() for playername, _ in minetest.get_auth_handler().iterate() do local entry = mail.get_storage_entry(playername) - local player_contacts = read_json_file(mail.maildir .. "/contacts/" .. playername .. ".json") + local player_contacts = read_json_file(maildir .. "/contacts/" .. playername .. ".json") for _, c in pairs(player_contacts) do table.insert(entry.contacts, { name = c.name, note = c.note }) end local saneplayername = string.gsub(playername, "[.|/]", "") - local player_inbox = read_json_file(mail.maildir .. "/" .. saneplayername .. ".json") + local player_inbox = read_json_file(maildir .. "/" .. saneplayername .. ".json") for _, msg in ipairs(player_inbox) do if msg.to then table.insert(entry.inbox, {