From 572ba83b3084e3d3abd294acb914746d29822a98 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 31 Jan 2019 16:35:55 +0000 Subject: Content store: Fix storage leak by storing screenshots in cache (#8137) --- src/script/lua_api/l_mainmenu.cpp | 11 +++++++++++ src/script/lua_api/l_mainmenu.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 9b9211593..9a64bd0ab 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -683,6 +683,12 @@ int ModApiMainMenu::l_get_texturepath_share(lua_State *L) 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) { 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"))) return true; + if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_cache))) + return true; + return false; } @@ -1043,6 +1052,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(get_gamepath); API_FCT(get_texturepath); API_FCT(get_texturepath_share); + API_FCT(get_cache_path); API_FCT(create_dir); API_FCT(delete_dir); API_FCT(copy_dir); @@ -1071,6 +1081,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top) API_FCT(get_gamepath); API_FCT(get_texturepath); API_FCT(get_texturepath_share); + API_FCT(get_cache_path); API_FCT(create_dir); API_FCT(delete_dir); API_FCT(copy_dir); diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 9e7792197..4a664359a 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -120,6 +120,8 @@ private: 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_delete_dir(lua_State *L); -- cgit v1.2.3