mirror of
https://github.com/aclist/dztui.git
synced 2026-10-31 07:02:50 +01:00
fix: only unlink stale links
This commit is contained in:
1 parent
dc310593d0
commit
645682ee06
1 file changed
+9
-4
@@ -15,14 +15,18 @@ def rebuild_symlinks(config: Path) -> None:
|
|||||||
steam_path = Path(path)
|
steam_path = Path(path)
|
||||||
|
|
||||||
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
||||||
|
# NOTE: unlink stale symlinks
|
||||||
for file in dayz_path.iterdir():
|
for file in dayz_path.iterdir():
|
||||||
if file.is_symlink():
|
if file.is_symlink() and file.exists() is False:
|
||||||
file.unlink()
|
file.unlink()
|
||||||
workshop = get_local_mod_path(steam_path)
|
workshop = get_local_mod_path(steam_path)
|
||||||
for uid in get_local_mod_ids(steam_path):
|
# NOTE: create symlinks for missing mods
|
||||||
uid = str(uid)
|
for mod_id in get_local_mod_ids(steam_path):
|
||||||
|
uid = str(mod_id)
|
||||||
md5sum = _hash(str(uid))
|
md5sum = _hash(str(uid))
|
||||||
Path(dayz_path / md5sum).symlink_to(workshop / uid)
|
source = Path(dayz_path / md5sum)
|
||||||
|
if source.exists() is False:
|
||||||
|
source.symlink_to(workshop / uid)
|
||||||
|
|
||||||
|
|
||||||
def clone_symlinks(config: Path) -> None:
|
def clone_symlinks(config: Path) -> None:
|
||||||
@@ -39,6 +43,7 @@ def clone_symlinks(config: Path) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# TODO: test these two operations
|
# TODO: test these two operations
|
||||||
|
# use less time intensive logic like the above
|
||||||
for file in exp_path.iterdir():
|
for file in exp_path.iterdir():
|
||||||
if file.is_symlink():
|
if file.is_symlink():
|
||||||
file.unlink()
|
file.unlink()
|
||||||
|
|||||||
Reference in new issue
Block a user