aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2021-09-25 19:44:40 +0200
committerBond_009 <bond.009@outlook.com>2021-09-25 19:44:40 +0200
commitf31224fa8f1dccb730703c048c26e14b5d14fa55 (patch)
tree0663fabcb48fa9f93ba4595b27b3f21499c5ae23 /Jellyfin.Api/Helpers/ProgressiveFileStream.cs
parent2ee3e9e00f62ff8b0139f1273d7666d0f6c549a4 (diff)
Remove sync FileStream hack
Diffstat (limited to 'Jellyfin.Api/Helpers/ProgressiveFileStream.cs')
-rw-r--r--Jellyfin.Api/Helpers/ProgressiveFileStream.cs24
1 files changed, 2 insertions, 22 deletions
diff --git a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
index c57018351..61e18220a 100644
--- a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
+++ b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
@@ -17,7 +17,6 @@ namespace Jellyfin.Api.Helpers
private readonly TranscodingJobDto? _job;
private readonly TranscodingJobHelper? _transcodingJobHelper;
private readonly int _timeoutMs;
- private readonly bool _allowAsyncFileRead;
private int _bytesWritten;
private bool _disposed;
@@ -34,17 +33,7 @@ namespace Jellyfin.Api.Helpers
_transcodingJobHelper = transcodingJobHelper;
_timeoutMs = timeoutMs;
- var fileOptions = FileOptions.SequentialScan;
- _allowAsyncFileRead = false;
-
- // use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039
- if (AsyncFile.UseAsyncIO)
- {
- fileOptions |= FileOptions.Asynchronous;
- _allowAsyncFileRead = true;
- }
-
- _stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, fileOptions);
+ _stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous | FileOptions.SequentialScan);
}
/// <summary>
@@ -57,7 +46,6 @@ namespace Jellyfin.Api.Helpers
_job = null;
_transcodingJobHelper = null;
_timeoutMs = timeoutMs;
- _allowAsyncFileRead = AsyncFile.UseAsyncIO;
_stream = stream;
}
@@ -103,15 +91,7 @@ namespace Jellyfin.Api.Helpers
while (remainingBytesToRead > 0)
{
cancellationToken.ThrowIfCancellationRequested();
- int bytesRead;
- if (_allowAsyncFileRead)
- {
- bytesRead = await _stream.ReadAsync(buffer, newOffset, remainingBytesToRead, cancellationToken).ConfigureAwait(false);
- }
- else
- {
- bytesRead = _stream.Read(buffer, newOffset, remainingBytesToRead);
- }
+ int bytesRead = await _stream.ReadAsync(buffer, newOffset, remainingBytesToRead, cancellationToken).ConfigureAwait(false);
remainingBytesToRead -= bytesRead;
newOffset += bytesRead;