Browse Source

Bug 1412: Failure when Session.MoveFile source file is not existing and its name has file mask-like syntax

https://winscp.net/tracker/1412

Source commit: da2e48c6077c0a421285eaf212957bf90eb10ca8
Martin Prikryl 9 years ago
parent
commit
ca30fede53
1 changed files with 12 additions and 3 deletions
  1. 12 3
      dotnet/Session.cs

+ 12 - 3
dotnet/Session.cs

@@ -942,10 +942,19 @@ namespace WinSCP
                 WriteCommand(string.Format(CultureInfo.InvariantCulture, "mv \"{0}\" \"{1}\"", Tools.ArgumentEscape(sourcePath), Tools.ArgumentEscape(targetPath)));
 
                 using (ElementLogReader groupReader = _reader.WaitForGroupAndCreateLogReader())
-                using (ElementLogReader mvReader = groupReader.WaitForNonEmptyElementAndCreateLogReader("mv", LogReadFlags.ThrowFailures))
                 {
-                    ReadElement(mvReader, 0);
-                    groupReader.ReadToEnd(LogReadFlags.ThrowFailures);
+                    if (!groupReader.TryWaitForNonEmptyElement("mv", LogReadFlags.ThrowFailures))
+                    {
+                        throw new SessionRemoteException(this, string.Format(CultureInfo.CurrentCulture, "{0} not found.", sourcePath));
+                    }
+                    else
+                    {
+                        using (ElementLogReader mvReader = groupReader.CreateLogReader())
+                        {
+                            ReadElement(mvReader, 0);
+                            groupReader.ReadToEnd(LogReadFlags.ThrowFailures);
+                        }
+                    }
                 }
             }
         }