mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Content store: Fix storage leak by storing screenshots in cache (#8137)
This commit is contained in:
parent
944e9f5acb
commit
572ba83b30
@ -19,7 +19,7 @@ local store = {}
|
|||||||
local package_dialog = {}
|
local package_dialog = {}
|
||||||
|
|
||||||
-- Screenshot
|
-- Screenshot
|
||||||
local screenshot_dir = os.tempfolder()
|
local screenshot_dir = core.get_cache_path() .. DIR_DELIM .. "cdb"
|
||||||
assert(core.create_dir(screenshot_dir))
|
assert(core.create_dir(screenshot_dir))
|
||||||
local screenshot_downloading = {}
|
local screenshot_downloading = {}
|
||||||
local screenshot_downloaded = {}
|
local screenshot_downloaded = {}
|
||||||
|
@ -65,6 +65,7 @@ core.get_video_drivers()
|
|||||||
^ first element of returned list is guaranteed to be the NULL driver
|
^ first element of returned list is guaranteed to be the NULL driver
|
||||||
core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
|
core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
|
||||||
registered in the core (possible in async calls)
|
registered in the core (possible in async calls)
|
||||||
|
core.get_cache_path() -> path of cache
|
||||||
|
|
||||||
Formspec:
|
Formspec:
|
||||||
core.update_formspec(formspec)
|
core.update_formspec(formspec)
|
||||||
|
@ -683,6 +683,12 @@ int ModApiMainMenu::l_get_texturepath_share(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ModApiMainMenu::l_get_cache_path(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_pushstring(L, fs::RemoveRelativePathComponents(porting::path_cache).c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
int ModApiMainMenu::l_create_dir(lua_State *L) {
|
int ModApiMainMenu::l_create_dir(lua_State *L) {
|
||||||
const char *path = luaL_checkstring(L, 1);
|
const char *path = luaL_checkstring(L, 1);
|
||||||
@ -855,6 +861,9 @@ bool ModApiMainMenu::mayModifyPath(const std::string &path)
|
|||||||
if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM "worlds")))
|
if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM "worlds")))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_cache)))
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1043,6 +1052,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
|
|||||||
API_FCT(get_gamepath);
|
API_FCT(get_gamepath);
|
||||||
API_FCT(get_texturepath);
|
API_FCT(get_texturepath);
|
||||||
API_FCT(get_texturepath_share);
|
API_FCT(get_texturepath_share);
|
||||||
|
API_FCT(get_cache_path);
|
||||||
API_FCT(create_dir);
|
API_FCT(create_dir);
|
||||||
API_FCT(delete_dir);
|
API_FCT(delete_dir);
|
||||||
API_FCT(copy_dir);
|
API_FCT(copy_dir);
|
||||||
@ -1071,6 +1081,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
|
|||||||
API_FCT(get_gamepath);
|
API_FCT(get_gamepath);
|
||||||
API_FCT(get_texturepath);
|
API_FCT(get_texturepath);
|
||||||
API_FCT(get_texturepath_share);
|
API_FCT(get_texturepath_share);
|
||||||
|
API_FCT(get_cache_path);
|
||||||
API_FCT(create_dir);
|
API_FCT(create_dir);
|
||||||
API_FCT(delete_dir);
|
API_FCT(delete_dir);
|
||||||
API_FCT(copy_dir);
|
API_FCT(copy_dir);
|
||||||
|
@ -120,6 +120,8 @@ private:
|
|||||||
|
|
||||||
static int l_get_texturepath_share(lua_State *L);
|
static int l_get_texturepath_share(lua_State *L);
|
||||||
|
|
||||||
|
static int l_get_cache_path(lua_State *L);
|
||||||
|
|
||||||
static int l_create_dir(lua_State *L);
|
static int l_create_dir(lua_State *L);
|
||||||
|
|
||||||
static int l_delete_dir(lua_State *L);
|
static int l_delete_dir(lua_State *L);
|
||||||
|
Loading…
Reference in New Issue
Block a user