Skip to content

Commit

Permalink
Merge pull request #141 from FrendsPlatform/issue-40
Browse files Browse the repository at this point in the history
Frends.SFTP.DownloadFiles - Added new result attribute for destination file paths
  • Loading branch information
ttossavainen authored May 17, 2023
2 parents 4aa60cb + 5e432ff commit af495ec
Show file tree
Hide file tree
Showing 9 changed files with 576 additions and 547 deletions.
4 changes: 4 additions & 0 deletions Frends.SFTP.DownloadFiles/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [2.6.0] - 2023-05-16
### Added
- Added new result attribute TransferredDestinationFilePaths list consisting of the destination file paths.

## [2.5.4] - 2023-02-14
### Added
- Re-enabled key exchange algorithms 'curve25519-sha256' and 'curve25519-sha256@libssh.org'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using System.IO;
using System;
using System.Linq;
using System.Threading;
using Frends.SFTP.DownloadFiles.Definitions;

Expand All @@ -22,7 +23,9 @@ public void DownloadFiles_TestUsingMacros()
var result = SFTP.DownloadFiles(_source, destination, _connection, _options, _info, new CancellationToken());
Assert.IsTrue(result.Success);
var date = DateTime.Now;
Assert.IsTrue(File.Exists(Path.Combine(_destWorkDir, "SFTPDownloadTestFile1" + date.ToString(@"yyyy-MM-dd") + ".txt")));
var file = Path.Combine(_destWorkDir, "SFTPDownloadTestFile1" + date.ToString(@"yyyy-MM-dd") + ".txt");
Assert.AreEqual(file, result.TransferredDestinationFilePaths.ToList().FirstOrDefault());
Assert.IsTrue(File.Exists(file));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Collections.Generic;
using Frends.SFTP.DownloadFiles.Definitions;
Expand All @@ -16,6 +17,7 @@ public void DownloadFiles_TestSimpleTransfer()
var result = SFTP.DownloadFiles(_source, _destination, _connection, _options, _info, new CancellationToken());
Assert.IsTrue(result.Success);
Assert.AreEqual(1, result.SuccessfulTransferCount);
Assert.AreEqual(Path.Combine(_destination.Directory, _source.FileName), result.TransferredDestinationFilePaths.ToList().FirstOrDefault());
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal class FileTransferResult

public IEnumerable<string> TransferredFilePaths { get; set; }

public IEnumerable<string> TransferredDestinationFilePaths { get; set; }

public IDictionary<string, string> OperationsLog { get; set; }
}

Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ private static FileTransferResult FormFailedFileTransferResult(string userResult
TransferredFileNames = new List<string>(),
TransferErrors = new Dictionary<string, IList<string>>(),
TransferredFilePaths = new List<string>(),
TransferredDestinationFilePaths = new List<string>(),
OperationsLog = new Dictionary<string, string>()
};
}
Expand Down Expand Up @@ -488,6 +489,7 @@ private FileTransferResult FormResultFromSingleTransferResults(List<SingleFileTr
TransferredFileNames = transferredFileResults.Select(r => r.TransferredFile ?? "--unknown--").ToList(),
TransferErrors = transferErrors,
TransferredFilePaths = transferredFileResults.Select(r => r.TransferredFilePath ?? "--unknown--").ToList(),
TransferredDestinationFilePaths = transferredFileResults.Select(s => s.DestinationFilePath ?? "--unknown--").ToList(),
OperationsLog = (singleResults.Any(x => !x.EnableOperationsLog)) ? null : new Dictionary<string, string>()
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,24 @@ public class Result
/// <example>
/// <code>
/// [
/// "C:\\test\\test.txt",
/// "C:\\test\\test2.txt"
/// "/Upload/upload/test.txt",
/// "/Upload/upload/test2.txt"
/// ]
/// </code>
/// </example>
public IEnumerable<string> TransferredFilePaths { get; private set; }

/// <summary>
/// List of destination file paths of the transferred files.
/// </summary>
/// <example>
/// [
/// "C:\\test\\test.txt",
/// "C:\\test\\test2.txt"
/// ]
/// </example>
public IEnumerable<string> TransferredDestinationFilePaths { get; private set; }

/// <summary>
/// Operations logs for the transfer.
/// </summary>
Expand All @@ -107,6 +118,7 @@ internal Result(FileTransferResult result)
TransferredFileNames = result.TransferredFileNames;
TransferErrors = result.TransferErrors;
TransferredFilePaths = result.TransferredFilePaths;
TransferredDestinationFilePaths = result.TransferredDestinationFilePaths;
OperationsLog = result.OperationsLog;
}
}
Expand Down
Loading

0 comments on commit af495ec

Please sign in to comment.