浏览代码

Bug 2087: Hang when entering small directories with FTP protocol

https://winscp.net/tracker/2087
(cherry picked from commit ee08afa721cbb8cb2c44e28a797db5efaeb84993)

Source commit: f12ddfd4cc959b4117c7b4f484fd51f7409f487f
Martin Prikryl 3 年之前
父节点
当前提交
2053e679f3
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7 5
      source/core/FtpFileSystem.cpp

+ 7 - 5
source/core/FtpFileSystem.cpp

@@ -1474,14 +1474,16 @@ void __fastcall TFTPFileSystem::ResetFileTransfer()
 //---------------------------------------------------------------------------
 void __fastcall TFTPFileSystem::ReadDirectoryProgress(__int64 Bytes)
 {
+  // with FTP we do not know exactly how many entries we have received,
+  // instead we know number of bytes received only.
+  // so we report approximation based on average size of entry.
+  int Progress = int(Bytes / 80);
   DWORD Ticks = GetTickCount();
-  if (Ticks - FLastReadDirectoryProgress >= 100)
+  if ((Ticks - FLastReadDirectoryProgress >= 100) &&
+      // Cannot call OnReadDirectoryProgress with 0 as it would unmatch the "starting" and "ending" signals for disabling the window
+      (Progress > 0))
   {
     FLastReadDirectoryProgress = Ticks;
-    // with FTP we do not know exactly how many entries we have received,
-    // instead we know number of bytes received only.
-    // so we report approximation based on average size of entry.
-    int Progress = int(Bytes / 80);
     bool Cancel = false;
     FTerminal->DoReadDirectoryProgress(Progress, 0, Cancel);
     if (Cancel)