diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs
index b79fa1640a..ddf3c69d27 100644
--- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs
+++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs
@@ -64,13 +64,6 @@ namespace Tgstation.Server.Host.IO
dir.Delete(true);
}
- ///
- /// Opens a for async writing at a given
- ///
- /// The path to open the at
- /// A new ready for async writing
- static FileStream OpenWriteStream(string path) => new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, DefaultBufferSize, true);
-
///
/// Copies a directory from to
///
@@ -143,8 +136,20 @@ namespace Tgstation.Server.Host.IO
throw new ArgumentNullException(nameof(src));
if (dest == null)
throw new ArgumentNullException(nameof(dest));
- using var srcStream = new FileStream(ResolvePath(src), FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete, DefaultBufferSize, true);
- using var destStream = new FileStream(ResolvePath(dest), FileMode.Create, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete, DefaultBufferSize, true);
+ using var srcStream = new FileStream(
+ ResolvePath(src),
+ FileMode.Open,
+ FileAccess.Read,
+ FileShare.Read | FileShare.Delete,
+ DefaultBufferSize,
+ FileOptions.Asynchronous | FileOptions.SequentialScan);
+ using var destStream = new FileStream(
+ ResolvePath(dest),
+ FileMode.Create,
+ FileAccess.Write,
+ FileShare.ReadWrite | FileShare.Delete,
+ DefaultBufferSize,
+ FileOptions.Asynchronous | FileOptions.SequentialScan);
// value taken from documentation
await srcStream.CopyToAsync(destStream, 81920, cancellationToken).ConfigureAwait(false);
@@ -229,7 +234,13 @@ namespace Tgstation.Server.Host.IO
public async Task ReadAllBytes(string path, CancellationToken cancellationToken)
{
path = ResolvePath(path);
- using var file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete, DefaultBufferSize, true);
+ using var file = new FileStream(
+ path,
+ FileMode.Open,
+ FileAccess.Read,
+ FileShare.ReadWrite | FileShare.Delete,
+ DefaultBufferSize,
+ FileOptions.Asynchronous | FileOptions.SequentialScan);
byte[] buf;
buf = new byte[file.Length];
await file.ReadAsync(buf, cancellationToken).ConfigureAwait(false);
@@ -246,7 +257,13 @@ namespace Tgstation.Server.Host.IO
public async Task WriteAllBytes(string path, byte[] contents, CancellationToken cancellationToken)
{
path = ResolvePath(path);
- using var file = OpenWriteStream(path);
+ using var file = new FileStream(
+ path,
+ FileMode.Create,
+ FileAccess.Write,
+ FileShare.ReadWrite,
+ DefaultBufferSize,
+ FileOptions.Asynchronous | FileOptions.SequentialScan);
await file.WriteAsync(contents, cancellationToken).ConfigureAwait(false);
}