Skip to content

Commit 14065fe

Browse files
committed
Improved locking for file moves and deletions
1 parent c5c0181 commit 14065fe

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Program.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,10 @@ private static async Task OnRenamedAsync(IRenamedFileSystemEvent fse, Cancellati
10971097
{
10981098
if (newFileIsWatchedFile)
10991099
{
1100-
await FileUpdated(newContext);
1100+
using (await FileEventLocks.LockAsync(fse.FileSystemInfo.FullName, token))
1101+
{
1102+
await FileUpdated(newContext);
1103+
}
11011104
}
11021105

11031106
if (prevFileIsWatchedFile)
@@ -1118,7 +1121,10 @@ private static async Task OnRenamedAsync(IRenamedFileSystemEvent fse, Cancellati
11181121
}
11191122
else
11201123
{
1121-
await FileDeleted(previousContext);
1124+
using (await FileEventLocks.LockAsync(prevFileFSE.FileSystemInfo.FullName, token))
1125+
{
1126+
await FileDeleted(previousContext);
1127+
}
11221128
}
11231129
}
11241130
}

0 commit comments

Comments
 (0)