Fix luacheck warnings in migrate.lua

This commit is contained in:
Athozus 2023-03-14 12:29:28 +01:00
parent 6605b1db47
commit 8d9c1aa43f
No known key found for this signature in database
GPG key ID: B50895022E8484BF

View file

@ -10,7 +10,6 @@ function mail.migrate()
end
end
-- migrate from mail.db to player-file-based mailbox
function mail.migrate_v1_to_v2()
-- create directory, just in case
@ -46,7 +45,6 @@ function mail.migrate_v2_to_v3()
end
end)
mail.migrate_messages_v2_to_v3()
local info_file = mail.read_json_file(mail.maildir .. "/mail.info.json")
mail.write_json_file(mail.maildir .. "/mail.info.json", { dbversion = 3.0 })
end
@ -58,7 +56,8 @@ function mail.migrate_messages_v2_to_v3()
local saneplayername = string.gsub(playername, "[.|/]", "")
local player_inbox = mail.read_json_file(mail.maildir .. "/" .. saneplayername .. ".json")
for _, msg in ipairs(player_inbox) do
local msg_id = tostring(msg.time) .. msg.sender -- id like "123456789.0singleplayer" -- it presumes that a same sender cannot send two mails within a second
-- id like "123456789.0singleplayer" -- it presumes that a same sender cannot send two mails within a second
local msg_id = tostring(msg.time) .. msg.sender
local new_msg = true -- check if that mail was already processed with another player
for _, cur_id in ipairs(already_processed) do
if cur_id == msg_id then
@ -87,13 +86,12 @@ end
function mail.migrate_contacts(playername)
local gen_file_v1 = io.open(minetest.get_worldpath().."/mail.db", "r")
if gen_file_v1 then
mail.migrate_contacts_v1_to_v2()
mail.migrate_contacts_v1_to_v2(playername)
end
-- v2 to v3 directly in general function
end
function mail.migrate_contacts_v1_to_v2(playername)
local file = io.open(mail.getContactsFile(playername), 'r')
if not file then