forked from metin-server/m2dev-server
fix symlinks
This commit is contained in:
22
install.py
22
install.py
@@ -3,6 +3,7 @@ sys.dont_write_bytecode = True
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import channels
|
import channels
|
||||||
|
|
||||||
GAMEDIR = os.getcwd()
|
GAMEDIR = os.getcwd()
|
||||||
@@ -61,12 +62,21 @@ def try_symlink(target, link_name, is_dir):
|
|||||||
try:
|
try:
|
||||||
if os.path.lexists(link_name):
|
if os.path.lexists(link_name):
|
||||||
os.remove(link_name)
|
os.remove(link_name)
|
||||||
if not is_dir and os.name == "nt":
|
|
||||||
target += ".exe"
|
if os.name == "nt": # Windows
|
||||||
link_name += ".exe"
|
if is_dir:
|
||||||
os.symlink(target, link_name, target_is_directory=is_dir)
|
# For directories, create junction
|
||||||
except OSError as e:
|
import subprocess
|
||||||
print(f"> Failed to create symlink: {link_name} -> {target} ({e})")
|
subprocess.run(["mklink", "/J", link_name, target], shell=True, check=True)
|
||||||
|
else:
|
||||||
|
# For files, copy instead of symlink
|
||||||
|
target += ".exe"
|
||||||
|
link_name += ".exe"
|
||||||
|
shutil.copy2(target, link_name)
|
||||||
|
else: # Unix-like systems
|
||||||
|
os.symlink(target, link_name, target_is_directory=is_dir)
|
||||||
|
except (OSError, subprocess.CalledProcessError) as e:
|
||||||
|
print(f"> Failed to create link: {link_name} -> {target} ({e})")
|
||||||
|
|
||||||
## Clearing Up Old Files
|
## Clearing Up Old Files
|
||||||
channels_dir = os.path.join(GAMEDIR, "channels")
|
channels_dir = os.path.join(GAMEDIR, "channels")
|
||||||
|
|||||||
Reference in New Issue
Block a user