Don't crash if a favorite server cannot be saved

master
luk3yx 2022-06-02 10:02:51 +12:00 committed by Maksim
parent 4765019103
commit 383e6ac053
1 changed files with 7 additions and 1 deletions

View File

@ -118,7 +118,9 @@ local function save_favorites(favorites)
core.settings:set("serverlist_file", filename:sub(1, #filename - 4) .. ".json")
end
assert(core.create_dir(get_favorites_path(true)))
if not core.create_dir(get_favorites_path(true)) then
core.log("error", "Failed to create favorites path")
end
core.safe_file_write(get_favorites_path(), core.write_json(favorites))
end
@ -240,6 +242,10 @@ end
--------------------------------------------------------------------------------
function serverlistmgr.add_favorite(new_favorite)
if new_favorite.address == nil or new_favorite.port == nil then
return
end
assert(type(new_favorite.port) == "number")
-- Whitelist favorite keys