浏览代码

FIX: Bug [0002644] Closing an unavailable FTP connection not possible

Alexander Koblov 2 年之前
父节点
当前提交
81e1cee3b8
共有 1 个文件被更改,包括 16 次插入7 次删除
  1. 16 7
      plugins/wfx/ftp/src/ftpfunc.pas

+ 16 - 7
plugins/wfx/ftp/src/ftpfunc.pas

@@ -931,22 +931,31 @@ function FsDisconnectW(DisconnectRoot: PWideChar): BOOL; dcpcall;
 var
   Index: Integer;
   asTemp: AnsiString;
-  wsTemp: UnicodeString;
   FtpSend: TFTPSendEx;
+  wsTemp: UnicodeString;
 begin
-  Result := False;
   wsTemp := ExcludeLeadingPathDelimiter(DisconnectRoot);
-  if GetConnectionByPath(wsTemp, FtpSend, asTemp) then
+  asTemp := ExtractConnectionName(UTF16ToUTF8(wsTemp));
+
+  Index := ActiveConnectionList.IndexOf(asTemp);
+  Result := (Index >= 0);
+
+  if Result then
   begin
-    Result := FtpSend.Logout;
+    FtpSend:= TFTPSendEx(ActiveConnectionList.Objects[Index]);
 
-    Index:= ConnectionList.IndexOf(ExtractConnectionName(UTF16ToUTF8(wsTemp)));
+    if not FtpSend.NetworkError then
+    begin
+      FtpSend.Logout;
+    end;
+    ActiveConnectionList.Delete(Index);
+
+    Index:= ConnectionList.IndexOf(asTemp);
     if Index >= 0 then begin
       ZeroPassword(TConnection(ConnectionList.Objects[Index]).CachedPassword);
     end;
-
     LogProc(PluginNumber, MSGTYPE_DISCONNECT, PWideChar('DISCONNECT ' + DisconnectRoot));
-    ActiveConnectionList.Delete(ActiveConnectionList.IndexOfObject(FtpSend));
+
     FreeAndNil(FtpSend);
   end;
 end;