Skip to content

Commit

Permalink
Fixed a bug where previous file contents wasn't always overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Sep 27, 2024
1 parent 4710041 commit a34363d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public async Task<bool> 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)
Expand All @@ -137,7 +137,7 @@ public async Task<bool> 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();
}

Expand Down

0 comments on commit a34363d

Please sign in to comment.