mirror of
https://github.com/mt-mods/mail.git
synced 2025-04-30 16:31:43 -04:00
Fix luacheck warnings in migrate.lua
This commit is contained in:
parent
6605b1db47
commit
8d9c1aa43f
1 changed files with 6 additions and 8 deletions
|
@ -10,7 +10,6 @@ function mail.migrate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- migrate from mail.db to player-file-based mailbox
|
-- migrate from mail.db to player-file-based mailbox
|
||||||
function mail.migrate_v1_to_v2()
|
function mail.migrate_v1_to_v2()
|
||||||
-- create directory, just in case
|
-- create directory, just in case
|
||||||
|
@ -46,7 +45,6 @@ function mail.migrate_v2_to_v3()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
mail.migrate_messages_v2_to_v3()
|
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 })
|
mail.write_json_file(mail.maildir .. "/mail.info.json", { dbversion = 3.0 })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,7 +56,8 @@ function mail.migrate_messages_v2_to_v3()
|
||||||
local saneplayername = string.gsub(playername, "[.|/]", "")
|
local saneplayername = string.gsub(playername, "[.|/]", "")
|
||||||
local player_inbox = mail.read_json_file(mail.maildir .. "/" .. saneplayername .. ".json")
|
local player_inbox = mail.read_json_file(mail.maildir .. "/" .. saneplayername .. ".json")
|
||||||
for _, msg in ipairs(player_inbox) do
|
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
|
local new_msg = true -- check if that mail was already processed with another player
|
||||||
for _, cur_id in ipairs(already_processed) do
|
for _, cur_id in ipairs(already_processed) do
|
||||||
if cur_id == msg_id then
|
if cur_id == msg_id then
|
||||||
|
@ -87,13 +86,12 @@ end
|
||||||
function mail.migrate_contacts(playername)
|
function mail.migrate_contacts(playername)
|
||||||
local gen_file_v1 = io.open(minetest.get_worldpath().."/mail.db", "r")
|
local gen_file_v1 = io.open(minetest.get_worldpath().."/mail.db", "r")
|
||||||
if gen_file_v1 then
|
if gen_file_v1 then
|
||||||
mail.migrate_contacts_v1_to_v2()
|
mail.migrate_contacts_v1_to_v2(playername)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- v2 to v3 directly in general function
|
-- v2 to v3 directly in general function
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function mail.migrate_contacts_v1_to_v2(playername)
|
function mail.migrate_contacts_v1_to_v2(playername)
|
||||||
local file = io.open(mail.getContactsFile(playername), 'r')
|
local file = io.open(mail.getContactsFile(playername), 'r')
|
||||||
if not file then
|
if not file then
|
||||||
|
|
Loading…
Add table
Reference in a new issue