Skip to content

Commit

Permalink
Fix crash when trying to overwrite a package
Browse files Browse the repository at this point in the history
Before minetest#11646, core.copy_dir would overwrite the target if it exists. Adding core.delete_dir restores the exact same behaviour

Fixes minetest#12303
  • Loading branch information
rubenwardy committed Aug 15, 2022
1 parent cae7ec1 commit 0090446
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin/mainmenu/pkgmgr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0090446

Please sign in to comment.