Skip to content

Commit

Permalink
[HSR] Fix DirectoryNotFoundException on RemoveHashMarkFile
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Dec 25, 2024
1 parent fdb5a50 commit d6e55fa
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions CollapseLauncher/Classes/RepairManagement/StarRail/Check.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Hi3Helper;
using CollapseLauncher.Helper;
using Hi3Helper;
using Hi3Helper.Data;
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.ClassStruct;
Expand Down Expand Up @@ -389,10 +390,18 @@ private static void RemoveHashMarkFile(string filePath, out string basePath, out
basePath = Path.GetDirectoryName(filePath);
baseName = Path.GetFileNameWithoutExtension(filePath);

// Get directory base info. If it doesn't exist, return
DirectoryInfo basePathDirInfo = new DirectoryInfo(basePath);
if (!basePathDirInfo.Exists)
{
return;
}

// Enumerate any possible existing hash path and delete it
foreach (string existingPath in Directory.EnumerateFiles(basePath!, $"{baseName}_*.hash"))
foreach (FileInfo existingPath in basePathDirInfo.EnumerateFiles($"{baseName}_*.hash")
.EnumerateNoReadOnly())
{
File.Delete(existingPath);
existingPath.Delete();
}
}
#endregion
Expand Down

0 comments on commit d6e55fa

Please sign in to comment.