From a34363dfa890b2ac590eed4c0df8b9a35f85b10c Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Thu, 26 Sep 2024 21:16:13 -0500 Subject: [PATCH] Fixed a bug where previous file contents wasn't always overwritten --- src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs b/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs index f4158be..f3babb1 100644 --- a/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs +++ b/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs @@ -128,7 +128,7 @@ public async Task SaveFileAsync(string path, Stream stream, CancellationTo try { - await using var sftpFileStream = await _client.OpenAsync(normalizedPath, FileMode.OpenOrCreate, FileAccess.Write, cancellationToken).AnyContext(); + await using var sftpFileStream = await _client.OpenAsync(normalizedPath, FileMode.Create, FileAccess.Write, cancellationToken).AnyContext(); await stream.CopyToAsync(sftpFileStream, cancellationToken).AnyContext(); } catch (SftpPathNotFoundException ex) @@ -137,7 +137,7 @@ public async Task SaveFileAsync(string path, Stream stream, CancellationTo CreateDirectory(normalizedPath); _logger.LogTrace("Saving {Path}", normalizedPath); - await using var sftpFileStream = await _client.OpenAsync(normalizedPath, FileMode.OpenOrCreate, FileAccess.Write, cancellationToken).AnyContext(); + await using var sftpFileStream = await _client.OpenAsync(normalizedPath, FileMode.Create, FileAccess.Write, cancellationToken).AnyContext(); await stream.CopyToAsync(sftpFileStream, cancellationToken).AnyContext(); }