diff options
author | sfan5 <sfan5@live.de> | 2021-04-02 16:31:44 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-04-05 16:02:32 +0200 |
commit | e5f802ab5cb32b242b0261000f8836a7da72a4bc (patch) | |
tree | db3cf0c20750dca8842efeafaac766cc4c299ae2 /builtin/mainmenu | |
parent | 847860fc5cf8867deb45646670ce1f11c3f977b0 (diff) | |
download | minetest-e5f802ab5cb32b242b0261000f8836a7da72a4bc.tar.gz minetest-e5f802ab5cb32b242b0261000f8836a7da72a4bc.tar.bz2 minetest-e5f802ab5cb32b242b0261000f8836a7da72a4bc.zip |
Fix server favorites not saving when client/serverlist/ doesn't exist already (#11152)
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r-- | builtin/mainmenu/serverlistmgr.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin/mainmenu/serverlistmgr.lua b/builtin/mainmenu/serverlistmgr.lua index 9876d8ac5..964d0c584 100644 --- a/builtin/mainmenu/serverlistmgr.lua +++ b/builtin/mainmenu/serverlistmgr.lua @@ -90,8 +90,11 @@ function serverlistmgr.sync() end -------------------------------------------------------------------------------- -local function get_favorites_path() +local function get_favorites_path(folder) local base = core.get_user_path() .. DIR_DELIM .. "client" .. DIR_DELIM .. "serverlist" .. DIR_DELIM + if folder then + return base + end return base .. core.settings:get("serverlist_file") end @@ -103,9 +106,8 @@ local function save_favorites(favorites) core.settings:set("serverlist_file", filename:sub(1, #filename - 4) .. ".json") end - local path = get_favorites_path() - core.create_dir(path) - core.safe_file_write(path, core.write_json(favorites)) + assert(core.create_dir(get_favorites_path(true))) + core.safe_file_write(get_favorites_path(), core.write_json(favorites)) end -------------------------------------------------------------------------------- |