Browse Source

Parallel file transfers were not working with more than 2 connections

Source commit: d66d41ffd07c57867869e6e1f427f6a97f482ba0
Martin Prikryl 2 years ago
parent
commit
f2b2e1c80c
1 changed files with 5 additions and 3 deletions
  1. 5 3
      source/core/SftpFileSystem.cpp

+ 5 - 3
source/core/SftpFileSystem.cpp

@@ -1438,10 +1438,11 @@ public:
   virtual __fastcall ~TSFTPDownloadQueue(){}
 
   bool __fastcall Init(
-    int QueueLen, const RawByteString & AHandle, __int64 ATransferred, __int64 PartSize, TFileOperationProgressType * AOperationProgress)
+    int QueueLen, const RawByteString & AHandle, __int64 Offset, __int64 PartSize, TFileOperationProgressType * AOperationProgress)
   {
     FHandle = AHandle;
-    FTransferred = ATransferred;
+    FOffset = Offset;
+    FTransferred = Offset;
     FPartSize = PartSize;
     OperationProgress = AOperationProgress;
 
@@ -1468,7 +1469,7 @@ protected:
     unsigned int BlockSize = FFileSystem->DownloadBlockSize(OperationProgress);
     if (FPartSize >= 0)
     {
-      __int64 Remaining = FPartSize - FTransferred;
+      __int64 Remaining = (FOffset + FPartSize) - FTransferred;
       if (Remaining < BlockSize)
       {
         // It's lower, so the cast is safe
@@ -1501,6 +1502,7 @@ protected:
 
 private:
   TFileOperationProgressType * OperationProgress;
+  __int64 FOffset;
   __int64 FTransferred;
   __int64 FPartSize;
   RawByteString FHandle;