Browse Source

Issue 2267 – Failure when canceling FTP connection while reading remote directory

https://winscp.net/tracker/2267
(cherry picked from commit c2b06d67df20720a8b43f4ae5182e268caaedd0a)

Source commit: 6a330e45dffac5acceccaeadc836617c040b12c7
Martin Prikryl 1 year ago
parent
commit
1e598b64c3
2 changed files with 4 additions and 5 deletions
  1. 4 4
      source/core/FtpFileSystem.cpp
  2. 0 1
      source/core/FtpFileSystem.h

+ 4 - 4
source/core/FtpFileSystem.cpp

@@ -247,7 +247,6 @@ __fastcall TFTPFileSystem::TFTPFileSystem(TTerminal * ATerminal):
   FFileList(NULL),
   FFileListCache(NULL),
   FActive(false),
-  FOpening(false),
   FWaitingForReply(false),
   FIgnoreFileList(false),
   FOnCaptureOutput(NULL),
@@ -497,7 +496,6 @@ void __fastcall TFTPFileSystem::Open()
     }
 
     FPasswordFailed = false;
-    TAutoFlag OpeningFlag(FOpening);
 
     FActive = FFileZillaIntf->Connect(
       HostName.c_str(), Data->PortNumber, UserName.c_str(),
@@ -548,8 +546,10 @@ void __fastcall TFTPFileSystem::Open()
 void __fastcall TFTPFileSystem::Close()
 {
   DebugAssert(FActive);
+
   bool Result;
-  if (FFileZillaIntf->Close(FOpening))
+  bool Opening = (FTerminal->Status == ssOpening);
+  if (FFileZillaIntf->Close(Opening))
   {
     DebugCheck(FLAGSET(WaitForCommandReply(false), TFileZillaIntf::REPLY_DISCONNECTED));
     Result = true;
@@ -557,7 +557,7 @@ void __fastcall TFTPFileSystem::Close()
   else
   {
     // See TFileZillaIntf::Close
-    Result = FOpening;
+    Result = Opening;
   }
 
   if (DebugAlwaysTrue(Result))

+ 0 - 1
source/core/FtpFileSystem.h

@@ -257,7 +257,6 @@ private:
   UnicodeString FFileListCachePath;
   UnicodeString FWelcomeMessage;
   bool FActive;
-  bool FOpening;
   bool FWaitingForReply;
   enum { ftaNone, ftaSkip, ftaCancel } FFileTransferAbort;
   bool FIgnoreFileList;