浏览代码

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 年之前
父节点
当前提交
4db4164115
共有 1 个文件被更改,包括 11 次插入2 次删除
  1. 11 2
      dotnet/Session.cs

+ 11 - 2
dotnet/Session.cs

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