Skip to content

Commit a2c80ed

Browse files
committed
Change FileShare to Read in GetFileHash to prevent external process locking conflicts
1 parent 3966807 commit a2c80ed

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/FileSystem/File.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ public static class File
4444
fullPath,
4545
FileMode.Open,
4646
FileAccess.Read,
47-
FileShare.None,
47+
FileShare.Read, // Allow other processes to read the file while we compute the hash
4848
MEGABYTE))
4949
{
5050
var hash = hashAlgorithm.ComputeHash(stream);
5151
return BitConverter.ToString(hash).Replace("-", "", StringComparison.OrdinalIgnoreCase);
5252
}
5353
}
5454
}
55-
catch (Exception ex)
56-
when (ex is ArgumentException || ex is ArgumentNullException || ex is ObjectDisposedException || ex is System.Reflection.TargetInvocationException)
55+
catch
5756
{
5857
return null;
5958
}

0 commit comments

Comments
 (0)