Browse Source

Bug 1526: Upload back files modified by local custom command applied to a folder

https://winscp.net/tracker/1526

Source commit: 3e3eefb28cd2b58def13af898a303e1c81068e10
Martin Prikryl 8 years ago
parent
commit
1087f7a6a8
1 changed files with 25 additions and 4 deletions
  1. 25 4
      source/forms/CustomScpExplorer.cpp

+ 25 - 4
source/forms/CustomScpExplorer.cpp

@@ -1725,6 +1725,7 @@ void __fastcall TCustomScpExplorerForm::LocalCustomCommandPure(
 {
 {
   TStrings * LocalFileList = NULL;
   TStrings * LocalFileList = NULL;
   TStrings * RemoteFileList = NULL;
   TStrings * RemoteFileList = NULL;
+  TStrings * RemoteFileListFull = NULL;
   try
   try
   {
   {
     if (LocalFileCommand)
     if (LocalFileCommand)
@@ -1790,6 +1791,23 @@ void __fastcall TCustomScpExplorerForm::LocalCustomCommandPure(
           FLAGSET(ACommand.Params, ccRecursive) && !FileListCommand;
           FLAGSET(ACommand.Params, ccRecursive) && !FileListCommand;
 
 
         ProcessLocalDirectory(TempDir, Terminal->MakeLocalFileList, &MakeFileListParam);
         ProcessLocalDirectory(TempDir, Terminal->MakeLocalFileList, &MakeFileListParam);
+
+        if (!MakeFileListParam.Recursive)
+        {
+          RemoteFileTimes.clear();
+
+          RemoteFileListFull = new TStringList();
+
+          MakeFileListParam.FileList = RemoteFileListFull;
+          MakeFileListParam.Recursive = true;
+          MakeFileListParam.IncludeDirs = false;
+
+          ProcessLocalDirectory(TempDir, Terminal->MakeLocalFileList, &MakeFileListParam);
+        }
+        else
+        {
+          RemoteFileListFull = RemoteFileList;
+        }
       }
       }
 
 
       bool NonBlocking = FileListCommand && RemoteFiles && !POutput;
       bool NonBlocking = FileListCommand && RemoteFiles && !POutput;
@@ -1898,12 +1916,11 @@ void __fastcall TCustomScpExplorerForm::LocalCustomCommandPure(
       if (!RemoteFiles)
       if (!RemoteFiles)
       {
       {
         TempDir = IncludeTrailingBackslash(TempDir);
         TempDir = IncludeTrailingBackslash(TempDir);
-        for (int Index = 0; Index < RemoteFileList->Count; Index++)
+        for (int Index = 0; Index < RemoteFileListFull->Count; Index++)
         {
         {
-          UnicodeString FileName = RemoteFileList->Strings[Index];
+          UnicodeString FileName = RemoteFileListFull->Strings[Index];
           if (DebugAlwaysTrue(SameText(TempDir, FileName.SubString(1, TempDir.Length()))) &&
           if (DebugAlwaysTrue(SameText(TempDir, FileName.SubString(1, TempDir.Length()))) &&
-              // Skip directories for now, they require recursion,
-              // and we do not have original nested files times available here yet.
+              // Skip directories, process only nested files.
               // The check is redundant as FileAge fails for directories anyway.
               // The check is redundant as FileAge fails for directories anyway.
               !DirectoryExists(FileName))
               !DirectoryExists(FileName))
           {
           {
@@ -1949,6 +1966,10 @@ void __fastcall TCustomScpExplorerForm::LocalCustomCommandPure(
     {
     {
       delete LocalFileList;
       delete LocalFileList;
     }
     }
+    if (RemoteFileListFull != RemoteFileList)
+    {
+      delete RemoteFileListFull;
+    }
   }
   }
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------