Remove sync FileStream hack

This commit is contained in:
Bond_009
2021-09-25 19:44:40 +02:00
parent 2ee3e9e00f
commit f31224fa8f
23 changed files with 29 additions and 56 deletions

View File

@@ -8,20 +8,13 @@ namespace MediaBrowser.Model.IO
/// </summary>
public static class AsyncFile
{
/// <summary>
/// Gets a value indicating whether we should use async IO on this platform.
/// <see href="https://github.com/dotnet/runtime/issues/16354" />.
/// </summary>
/// <returns>Returns <c>false</c> on Windows; otherwise <c>true</c>.</returns>
public static bool UseAsyncIO => !OperatingSystem.IsWindows();
/// <summary>
/// Opens an existing file for reading.
/// </summary>
/// <param name="path">The file to be opened for reading.</param>
/// <returns>A read-only <see cref="FileStream" /> on the specified path.</returns>
public static FileStream OpenRead(string path)
=> new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, UseAsyncIO);
=> new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
/// <summary>
/// Opens an existing file for writing.
@@ -29,6 +22,6 @@ namespace MediaBrowser.Model.IO
/// <param name="path">The file to be opened for writing.</param>
/// <returns>An unshared <see cref="FileStream" /> object on the specified path with Write access.</returns>
public static FileStream OpenWrite(string path)
=> new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, UseAsyncIO);
=> new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
}
}