Ver código fonte

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
rubenwardy 1 ano atrás
pai
commit
50df5e2f59
1 arquivos alterados com 3 adições e 3 exclusões
  1. 3 3
      builtin/mainmenu/pkgmgr.lua

+ 3 - 3
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)