Przeglądaj źródła

Bug 1513: Do not invoke Session.Failed when checking for non-existing file with Session.FileExists

https://winscp.net/tracker/1513

Source commit: 56e68f76430ee3c43b4f3777116e3450741f578e
Martin Prikryl 8 lat temu
rodzic
commit
4db4164115
1 zmienionych plików z 11 dodań i 2 usunięć
  1. 11 2
      dotnet/Session.cs

+ 11 - 2
dotnet/Session.cs

@@ -946,7 +946,15 @@ namespace WinSCP
 
 
                 try
                 try
                 {
                 {
-                    DoGetFileInfo(path);
+                    _ignoreFailed = true;
+                    try
+                    {
+                        DoGetFileInfo(path);
+                    }
+                    finally
+                    {
+                        _ignoreFailed = false;
+                    }
                     return true;
                     return true;
                 }
                 }
                 catch (SessionRemoteException)
                 catch (SessionRemoteException)
@@ -1765,7 +1773,7 @@ namespace WinSCP
         {
         {
             Logger.WriteLine("Failed: [{0}]", e);
             Logger.WriteLine("Failed: [{0}]", e);
 
 
-            if (Failed != null)
+            if ((Failed != null) && !_ignoreFailed)
             {
             {
                 Failed(this, new FailedEventArgs { Error = e });
                 Failed(this, new FailedEventArgs { Error = e });
             }
             }
@@ -2223,5 +2231,6 @@ namespace WinSCP
         private string _executableProcessUserName;
         private string _executableProcessUserName;
         private SecureString _executableProcessPassword;
         private SecureString _executableProcessPassword;
         private StringCollection _error;
         private StringCollection _error;
+        private bool _ignoreFailed;
     }
     }
 }
 }