Use RandomAccess instead of a FileStream where it makes sense
This commit is contained in:
parent
2ee3e9e00f
commit
a4eede29ab
|
@ -246,9 +246,9 @@ namespace Emby.Server.Implementations.IO
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (Stream thisFileStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, 1))
|
using (var fileHandle = File.OpenHandle(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
{
|
{
|
||||||
result.Length = thisFileStream.Length;
|
result.Length = RandomAccess.GetLength(fileHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException ex)
|
catch (FileNotFoundException ex)
|
||||||
|
|
|
@ -55,8 +55,8 @@ namespace Jellyfin.Server.Infrastructure
|
||||||
// This may or may not be fixed in .NET 6, but looks like it will not https://github.com/dotnet/aspnetcore/issues/34371
|
// This may or may not be fixed in .NET 6, but looks like it will not https://github.com/dotnet/aspnetcore/issues/34371
|
||||||
if ((fileInfo.Attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint)
|
if ((fileInfo.Attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint)
|
||||||
{
|
{
|
||||||
using Stream thisFileStream = File.OpenRead(path);
|
using var fileHandle = File.OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
length = thisFileStream.Length;
|
length = RandomAccess.GetLength(fileHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FileMetadata
|
return new FileMetadata
|
||||||
|
|
Loading…
Reference in New Issue
Block a user