Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Temp folder lock file moved outside folder to prevent it being copied
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Apr 26, 2023
1 parent 4254f5b commit f49f223
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Squirrel/Internal/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,12 @@ public static IDisposable WithTempDirectory(out string path, string localAppDire

// Directory.CreateDirectory will work even if the directory already exists. If two instances of
// Squirrel attempt to create the same temp directory at the same time, they can end up reading
// and writing on top of each other. So, here we create a new file in the temp folder we've selected
// and attempt to open it exclusively. This will act like a mutex as only one Squirre instance will
// be able to open this file.
// and writing on top of each other. So, here we create a new file of the same name as the temp
// folder we've selected and attempt to open it exclusively. This will act like a mutex as only
// one Squirrel instance will be able to open this file.

try {
folderMutex = File.Create(Path.Combine(tempDir.FullName, "lock"), 1, FileOptions.DeleteOnClose);
folderMutex = File.Create(tempDir.FullName + "_lock", 1, FileOptions.DeleteOnClose);
break;
} catch (IOException ex) {
Log().WarnException($"Selected temp folder '{tempDir.FullName}' but unable to open file mutex.", ex);
Expand Down

0 comments on commit f49f223

Please sign in to comment.