Skip to content

Commit

Permalink
Fix: Technically possible race condition where source or dest file is…
Browse files Browse the repository at this point in the history
… opened during package copy
  • Loading branch information
Sewer56 committed Mar 30, 2024
1 parent 3b80095 commit df427c3
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions source/Reloaded.Mod.Loader.IO/Utility/IOEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@ public static void MoveDirectory(string source, string target)
// Get destination file path
var destFileName = Path.GetFileName(sourceFilePath);
var destFilePath = Path.Combine(target, destFileName);

while (File.Exists(destFilePath) && !CheckFileAccess(destFilePath, FileMode.Open, FileAccess.Write))
Thread.Sleep(100);

while (File.Exists(sourceFilePath) && !CheckFileAccess(sourceFilePath, FileMode.Open, FileAccess.Write))
Thread.Sleep(100);

if (File.Exists(destFilePath))
File.Delete(destFilePath);

File.Move(sourceFilePath, destFilePath);
MoveFile(sourceFilePath, destFilePath);
}

// Get all subdirectories in source directory.
Expand Down

0 comments on commit df427c3

Please sign in to comment.