فهرست منبع

Bug 1859: Empty directories are not uploaded to FTP server when transferring in background

https://winscp.net/tracker/1859

Source commit: e5240d0b54bab3fbf68ba0c63bf2eab388d75e98
Martin Prikryl 5 سال پیش
والد
کامیت
71019943e6
1فایلهای تغییر یافته به همراه30 افزوده شده و 27 حذف شده
  1. 30 27
      source/core/Terminal.cpp

+ 30 - 27
source/core/Terminal.cpp

@@ -6975,7 +6975,8 @@ void __fastcall TTerminal::DirectorySource(
     }
   }
 
-  if (FLAGCLEAR(Params, cpNoRecurse))
+  bool DoRecurse = FLAGCLEAR(Params, cpNoRecurse);
+  if (DoRecurse)
   {
     TSearchRecOwned SearchRec;
     bool FindOK = LocalFindFirstLoop(DirectoryName + L"*.*", SearchRec);
@@ -7009,42 +7010,44 @@ void __fastcall TTerminal::DirectorySource(
     }
 
     SearchRec.Close();
+  }
 
-    // FTP
-    if (PostCreateDir)
-    {
-      CreateTargetDirectory(DestFullName, Attrs, CopyParam);
-    }
+  // FTP
+  if (PostCreateDir)
+  {
+    CreateTargetDirectory(DestFullName, Attrs, CopyParam);
+  }
 
+  // Paralell transfers (cpNoRecurse) won't be allowed if any of these are set anyway (see CanParallel).
+  // Exception is ClearArchive, which is does not prevent parallel transfer, but is silently ignored for directories.
+  if (DoRecurse && !OperationProgress->Cancel)
+  {
     // TODO : Delete also read-only directories.
     // TODO : Show error message on failure.
-    if (!OperationProgress->Cancel)
+    if (IsCapable[fcPreservingTimestampDirs] && CopyParam->PreserveTime && CopyParam->PreserveTimeDirs)
     {
-      if (IsCapable[fcPreservingTimestampDirs] && CopyParam->PreserveTime && CopyParam->PreserveTimeDirs)
-      {
-        TRemoteProperties Properties;
-        Properties.Valid << vpModification;
+      TRemoteProperties Properties;
+      Properties.Valid << vpModification;
 
-        OpenLocalFile(
-          ExcludeTrailingBackslash(DirectoryName), GENERIC_READ, NULL, NULL, NULL,
-          &Properties.Modification, &Properties.LastAccess, NULL);
+      OpenLocalFile(
+        ExcludeTrailingBackslash(DirectoryName), GENERIC_READ, NULL, NULL, NULL,
+        &Properties.Modification, &Properties.LastAccess, NULL);
 
-        ChangeFileProperties(DestFullName, NULL, &Properties);
-      }
+      ChangeFileProperties(DestFullName, NULL, &Properties);
+    }
 
-      if (FLAGSET(Params, cpDelete))
-      {
-        DebugAssert(FLAGCLEAR(Params, cpNoRecurse));
-        RemoveDir(ApiPath(DirectoryName));
-      }
-      else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive))
+    if (FLAGSET(Params, cpDelete))
+    {
+      DebugAssert(FLAGCLEAR(Params, cpNoRecurse));
+      RemoveDir(ApiPath(DirectoryName));
+    }
+    else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive))
+    {
+      FILE_OPERATION_LOOP_BEGIN
       {
-        FILE_OPERATION_LOOP_BEGIN
-        {
-          THROWOSIFFALSE(FileSetAttr(ApiPath(DirectoryName), Attrs & ~faArchive) == 0);
-        }
-        FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DirectoryName)));
+        THROWOSIFFALSE(FileSetAttr(ApiPath(DirectoryName), Attrs & ~faArchive) == 0);
       }
+      FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DirectoryName)));
     }
   }
 }