robinrodricks / FluentStorage

A polycloud .NET cloud storage abstraction layer. Provides Blob storage (AWS S3, GCP, FTP, SFTP, Azure Blob/File/Event Hub/Data Lake) and Messaging (AWS SQS, Azure Queue/ServiceBus). Supports .NET 5+ and .NET Standard 2.0+. Pure C#.
MIT License
263 stars 33 forks source link

Set length of destination stream manually to avoid resulting data bei… #57

Closed beeradmoore closed 7 months ago

beeradmoore commented 7 months ago

…ng left

Fixes

Issue #52 Issue #58

Description

For issue 52, This PR fixes the issue here, but it may be preferred to fix the issue in SSH.NET itself.

For issue 58, Adjusting the way we open the file allows us to append data. Doing so we also need to exclude the usage of dest.SetLength( as it would truncate the destination file to the length of the source file.

Considering this I now wonder if there are situations when dataStream.Length may not exist or be accurate. Should this code check that dataStream.Length > 0 before it attempts to set the length? Not doing so could cause the entire file to be wiped out.

robinrodricks commented 7 months ago

Looks good, thanks!

robinrodricks commented 7 months ago

Released!

https://www.nuget.org/packages/FluentStorage.SFTP/5.3.0