Skip to content

Commit

Permalink
Fixed issue delete acf if steam had replaced the symlink with a fresh…
Browse files Browse the repository at this point in the history
… copy
  • Loading branch information
MrPurple6411 committed Feb 21, 2022
1 parent 6658cbd commit df932e6
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions BranchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ private static bool CreateGameBranch(string gamePath, string acfPath, string bra
internal static void SetActiveBranch(string gamePath, string acfPath, string branchName)
{
FileInfo acfPathInfo = new FileInfo(acfPath);
if (acfPathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint))
if (File.Exists($"{gamePath}Branches/{branchName}/{Path.GetFileName(acfPath)}") &&
(acfPathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint) || acfPathInfo.Exists))
{
File.Delete(acfPath);
CreateSymbolicLink(acfPath, $"{gamePath}Branches/{branchName}/{Path.GetFileName(acfPath)}", SymbolicLink.File);
}

DirectoryInfo gamePathInfo = new DirectoryInfo(gamePath);
if (gamePathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint))
if (Directory.Exists($"{gamePath}Branches/{branchName}") && gamePathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint))
{
gamePathInfo.Delete();
CreateSymbolicLink(gamePath, $"{gamePath}Branches/{branchName}", SymbolicLink.Directory);
}

CreateSymbolicLink(acfPath, $"{gamePath}Branches/{branchName}/{Path.GetFileName(acfPath)}", SymbolicLink.File);
CreateSymbolicLink(gamePath, $"{gamePath}Branches/{branchName}", SymbolicLink.Directory);
}
private static void CopyDirectory(string sourceDir, string destinationDir, bool recursive, bool deep,
BackgroundWorker worker)
Expand Down Expand Up @@ -227,18 +232,22 @@ private static bool DeleteGameBranch(string gamePath, string acfPath, string bra
if (branchName == "original")
{
FileInfo acfPathInfo = new FileInfo(acfPath);
if (acfPathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint))
File.Delete(acfPath);

if (File.Exists($"{gamePath}Branches/{branchName}/{Path.GetFileName(acfPath)}"))
if (File.Exists($"{gamePath}Branches/{branchName}/{Path.GetFileName(acfPath)}") &&
(acfPathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint) || acfPathInfo.Exists))
{
acfPathInfo.Delete();
File.Move($"{gamePath}Branches/{branchName}/{Path.GetFileName(acfPath)}", acfPath);
}


DirectoryInfo gamePathInfo = new DirectoryInfo(gamePath);
if (gamePathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint))
if (Directory.Exists($"{gamePath}Branches/{branchName}") &&
gamePathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint))
{
gamePathInfo.Delete();

if (Directory.Exists($"{gamePath}Branches/{branchName}"))
Directory.Move($"{gamePath}Branches/{branchName}", gamePath);
}

}
else
{
Expand Down

0 comments on commit df932e6

Please sign in to comment.