Commit 6e4326d3 authored by Benjamin Winger's avatar Benjamin Winger

Added check to handle when install location already exists

This comes up when the installed db is corrupt, for example when a breaking change has been made.
While this generally won't be a problem on stable versions, it is useful in case a breaking change was made in development.
Note that it is perfectly safe to remove the existing directory, as the user should not be manually installing mods
and this would only be a directory in the portmod local dir
parent 796d9a0f
......@@ -11,6 +11,7 @@ from portmod.repo.download import download_mod
from portmod.repo.loader import load_installed_mod
from portmod.colour import colour
from portmod.repo import Atom
from .log import warn
def remove_mod(mod, reinstall=False):
......@@ -97,6 +98,14 @@ def install_mod(mod):
mod.mod_postinst()
print("Installing into {}".format(final_install))
if os.path.exists(final_install):
warn("Installed directory already existed. Overwriting.")
if os.path.islink(final_install):
os.remove(final_install)
else:
shutil.rmtree(final_install)
# base/morrowind links the D directory to the morrowind install.
# Copy the link, not the morrowind install
if os.path.islink(mod.D):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment