Skip to content

Commit

Permalink
modified so that chunk size is adjusted only if TransferChunkSize is …
Browse files Browse the repository at this point in the history
…omitted
  • Loading branch information
wakabayashik committed Sep 5, 2019
1 parent f5375bc commit f0fd156
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions FluentFTP/Client/FtpClient_HighLevelDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,11 @@ private bool DownloadFileInternal(string remotePath, Stream outStream, long rest
var readToEnd = fileLen <= 0;

const int rateControlResolution = 100;
const int chunkSizeMin = 64;
var rateLimitBytes = DownloadRateLimit != 0 ? (long)DownloadRateLimit * 1024 : 0;
var chunkSize = Math.Max(TransferChunkSize, chunkSizeMin);
if (rateLimitBytes > 0) {
var chunkSize = TransferChunkSize;
if (m_transferChunkSize == null && rateLimitBytes > 0) {
// reduce chunk size to optimize rate control
const int chunkSizeMin = 64;
while (chunkSize > chunkSizeMin) {
var chunkLenInMs = 1000L * chunkSize / rateLimitBytes;
if (chunkLenInMs <= rateControlResolution) {
Expand Down Expand Up @@ -754,11 +754,11 @@ private bool DownloadFileInternal(string remotePath, Stream outStream, long rest
var readToEnd = fileLen <= 0;

const int rateControlResolution = 100;
const int chunkSizeMin = 64;
var rateLimitBytes = DownloadRateLimit != 0 ? (long)DownloadRateLimit * 1024 : 0;
var chunkSize = Math.Max(TransferChunkSize, chunkSizeMin);
if (rateLimitBytes > 0) {
var chunkSize = TransferChunkSize;
if (m_transferChunkSize == null && rateLimitBytes > 0) {
// reduce chunk size to optimize rate control
const int chunkSizeMin = 64;
while (chunkSize > chunkSizeMin) {
var chunkLenInMs = 1000L * chunkSize / rateLimitBytes;
if (chunkLenInMs <= rateControlResolution) {
Expand Down
12 changes: 6 additions & 6 deletions FluentFTP/Client/FtpClient_HighLevelUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,11 @@ private bool UploadFileInternal(Stream fileData, string remotePath, bool createR
}

const int rateControlResolution = 100;
const int chunkSizeMin = 64;
var rateLimitBytes = UploadRateLimit != 0 ? (long)UploadRateLimit * 1024 : 0;
var chunkSize = Math.Max(TransferChunkSize, chunkSizeMin);
if (rateLimitBytes > 0) {
var chunkSize = TransferChunkSize;
if (m_transferChunkSize == null && rateLimitBytes > 0) {
// reduce chunk size to optimize rate control
const int chunkSizeMin = 64;
while (chunkSize > chunkSizeMin) {
var chunkLenInMs = 1000L * chunkSize / rateLimitBytes;
if (chunkLenInMs <= rateControlResolution) {
Expand Down Expand Up @@ -893,11 +893,11 @@ private bool UploadFileInternal(Stream fileData, string remotePath, bool createR
}

const int rateControlResolution = 100;
const int chunkSizeMin = 64;
var rateLimitBytes = UploadRateLimit != 0 ? (long)UploadRateLimit * 1024 : 0;
var chunkSize = Math.Max(TransferChunkSize, chunkSizeMin);
if (rateLimitBytes > 0) {
var chunkSize = TransferChunkSize;
if (m_transferChunkSize == null && rateLimitBytes > 0) {
// reduce chunk size to optimize rate control
const int chunkSizeMin = 64;
while (chunkSize > chunkSizeMin) {
var chunkLenInMs = 1000L * chunkSize / rateLimitBytes;
if (chunkLenInMs <= rateControlResolution) {
Expand Down
4 changes: 2 additions & 2 deletions FluentFTP/Client/FtpClient_Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,15 @@ public int BulkListingLength {
}


private int m_transferChunkSize = 65536;
private int? m_transferChunkSize;

/// <summary>
/// Gets or sets the number of bytes transferred in a single chunk (a single FTP command).
/// Used by <see cref="o:UploadFile"/>/<see cref="o:UploadFileAsync"/> and <see cref="o:DownloadFile"/>/<see cref="o:DownloadFileAsync"/>
/// to transfer large files in multiple chunks.
/// </summary>
public int TransferChunkSize {
get => m_transferChunkSize;
get => m_transferChunkSize ?? 65536;
set => m_transferChunkSize = value;
}

Expand Down

0 comments on commit f0fd156

Please sign in to comment.