diff --git a/src/EntryPoint.cs b/src/EntryPoint.cs index 1588d25..30bba4c 100644 --- a/src/EntryPoint.cs +++ b/src/EntryPoint.cs @@ -12,6 +12,6 @@ internal static void Main() // must be loaded { LevelTick.InitHook(); GlobalService.Global.Init(); - PackHelper.Main.Init(); + PackHelper.PackHelper.Init(); } } diff --git a/src/PackHelper/LinkCreator.cs b/src/PackHelper/LinkCreator.cs index ad51749..2ab56ad 100644 --- a/src/PackHelper/LinkCreator.cs +++ b/src/PackHelper/LinkCreator.cs @@ -26,8 +26,24 @@ public static void AddPack(PackType packType, string packDirectory, PackInfo inf ); if (!Directory.Exists(target)) Directory.CreateDirectory(target); - var targetDir = Path.Combine(target, info.PackId.ToString()); - LinkUtils.CreateDirectorySymlink(targetDir, packDirectory); + var link = Path.Combine(target, info.PackId.ToString()); + if (Directory.Exists(link)) + { + if (LinkUtils.IsLink(link)) + { + var current = LinkUtils.ReadLink(link); + if (current == packDirectory) + { + LinkUtils.Unlink(link); + } + } + else + { + Directory.Delete(link, true); + } + } + if (!Directory.Exists(link)) + LinkUtils.CreateDirectorySymlink(link, packDirectory); if (packType is PackType.BehaviorPack) AddBehaviorPack(info); else diff --git a/src/PackHelper/PackHelper.cs b/src/PackHelper/PackHelper.cs index 4b6e000..e21e4b5 100644 --- a/src/PackHelper/PackHelper.cs +++ b/src/PackHelper/PackHelper.cs @@ -16,7 +16,7 @@ public PackAlreadyAddedException(Guid packId) : base($"Pack {packId} already added.") { } } -public static partial class Main +public static partial class PackHelper { private static List? ResourcePacks = new(); private static List? BehaviorPacks = new();