aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2022-08-15 08:30:46 +0100
committersfan5 <sfan5@live.de>2022-09-14 13:48:06 +0200
commit50df5e2f59d173abaf7759c67cfd4322dcac516c (patch)
tree0c2ad924c7beac7bbf6b679dc54333410e532335
parentb6db2c7262ada25f7cd5856dd81d2128eba768ef (diff)
downloadminetest-50df5e2f59d173abaf7759c67cfd4322dcac516c.tar.gz
minetest-50df5e2f59d173abaf7759c67cfd4322dcac516c.tar.bz2
minetest-50df5e2f59d173abaf7759c67cfd4322dcac516c.zip
Fix crash when trying to overwrite a package
Before #11646, core.copy_dir would overwrite the target if it exists. Adding core.delete_dir restores the exact same behaviour Fixes #12303
-rw-r--r--builtin/mainmenu/pkgmgr.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua
index 32a65fd08..853509b4f 100644
--- a/builtin/mainmenu/pkgmgr.lua
+++ b/builtin/mainmenu/pkgmgr.lua
@@ -608,11 +608,10 @@ function pkgmgr.install_dir(type, path, basename, targetpath)
end
local from = basefolder and basefolder.path or path
- if targetpath then
- core.delete_dir(targetpath)
- else
+ if not targetpath then
targetpath = core.get_texturepath() .. DIR_DELIM .. basename
end
+ core.delete_dir(targetpath)
if not core.copy_dir(from, targetpath, false) then
return nil,
fgettext("Failed to install $1 to $2", basename, targetpath)
@@ -690,6 +689,7 @@ function pkgmgr.install_dir(type, path, basename, targetpath)
end
-- Copy it
+ core.delete_dir(targetpath)
if not core.copy_dir(basefolder.path, targetpath, false) then
return nil,
fgettext("Failed to install $1 to $2", basename, targetpath)