Skip to content

Commit

Permalink
fix: link error
Browse files Browse the repository at this point in the history
  • Loading branch information
LazuliKao committed Jul 28, 2023
1 parent d6e54fa commit 80da85a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ internal static void Main() // must be loaded
{
LevelTick.InitHook();
GlobalService.Global.Init();
PackHelper.Main.Init();
PackHelper.PackHelper.Init();
}
}
20 changes: 18 additions & 2 deletions src/PackHelper/LinkCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/PackHelper/PackHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PackInfo>? ResourcePacks = new();
private static List<PackInfo>? BehaviorPacks = new();
Expand Down

0 comments on commit 80da85a

Please sign in to comment.