Browse Source

Bug fix: ComparisonDifference.IsDirectory was not set to true for directories

Source commit: aec465200bdc4dd2a59473da992b22f6e9a29257
Martin Prikryl 6 years ago
parent
commit
0dd8ae2347
2 changed files with 10 additions and 1 deletions
  1. 6 1
      dotnet/RemoteFileInfo.cs
  2. 4 0
      dotnet/Session.cs

+ 6 - 1
dotnet/RemoteFileInfo.cs

@@ -21,7 +21,7 @@ namespace WinSCP
         public string Owner { get; internal set; }
         public string Group { get; internal set; }
 
-        public bool IsDirectory { get { return (char.ToUpper(FileType, CultureInfo.InvariantCulture) == 'D'); } }
+        public bool IsDirectory { get { return IsDirectoryFileType(FileType); } }
         public bool IsThisDirectory { get { return IsDirectory && (Name == "."); } }
         public bool IsParentDirectory { get { return IsDirectory && (Name == ".."); } }
 
@@ -43,5 +43,10 @@ namespace WinSCP
         {
             Length = value;
         }
+
+        internal static bool IsDirectoryFileType(char fileType)
+        {
+            return (char.ToUpper(fileType, CultureInfo.InvariantCulture) == 'D');
+        }
     }
 }

+ 4 - 0
dotnet/Session.cs

@@ -1240,6 +1240,10 @@ namespace WinSCP
                                         throw Logger.WriteException(new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unknown synchronization action \"{0}\"", actionName)));
                                     }
                                 }
+                                else if (differenceReader.GetEmptyElementValue("type", out string fileType))
+                                {
+                                    difference.IsDirectory = (fileType.Length == 1) && RemoteFileInfo.IsDirectoryFileType(fileType[0]);
+                                }
                                 else if (differenceReader.GetEmptyElementValue("filename", out string value))
                                 {
                                     if (current == null)