Truncate local file in ScpClient.Download (#1729)

Similar to #1686 but for the local side of SCP: opening the file should use
Create not OpenWrite.

closes #648
This commit is contained in:
Rob Hague
2025-11-21 19:53:44 +01:00
committed by GitHub
parent 391065830a
commit 330e9331e9
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -824,7 +824,7 @@ namespace Renci.SshNet
fileInfo = new FileInfo(Path.Combine(currentDirectoryFullName, fileName));
}
using (var output = fileInfo.OpenWrite())
using (var output = fileInfo.Open(FileMode.Create, FileAccess.Write))
{
InternalDownload(channel, input, output, fileName, length);
}
@@ -679,7 +679,8 @@ namespace Renci.SshNet.IntegrationTests
}
}
var fileInfo = new FileInfo(Path.GetTempFileName());
// Create a local file larger than the remote file in order to test truncation.
var fileInfo = new FileInfo(CreateTempFile(size + 64));
try
{