소스 검색

Correcting Bug 99 implementation: New timestamp was not stored after upload form external editor + After refusing to overwrite, the next save was uploaded without asking

Source commit: cb744a4246cbba20f19b4d69b2dc86bd30695ab8
Martin Prikryl 2 년 전
부모
커밋
2983a6ef47
4개의 변경된 파일15개의 추가작업 그리고 12개의 파일을 삭제
  1. 6 3
      source/forms/CustomScpExplorer.cpp
  2. 1 1
      source/forms/CustomScpExplorer.h
  3. 6 6
      source/windows/EditorManager.cpp
  4. 2 2
      source/windows/EditorManager.h

+ 6 - 3
source/forms/CustomScpExplorer.cpp

@@ -4190,9 +4190,9 @@ void __fastcall TCustomScpExplorerForm::ExecutedFileEarlyClosed(
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::ExecutedFileUploadComplete(TEditedFileData * Data, TObject * Sender)
+void __fastcall TCustomScpExplorerForm::ExecutedFileUploadComplete(TEditedFileData * Data, TObject * Sender, bool Failed)
 {
-  if (EditorCheckNotModified(Data))
+  if (!Failed && EditorCheckNotModified(Data))
   {
     UnicodeString RemoteFilePath = UnixCombinePaths(Data->RemoteDirectory, Data->OriginalFileName);
     std::unique_ptr<TRemoteFile> File(Terminal->TryReadFile(RemoteFilePath));
@@ -4203,7 +4203,10 @@ void __fastcall TCustomScpExplorerForm::ExecutedFileUploadComplete(TEditedFileDa
     }
   }
 
-  EditorFormFileUploadComplete(DebugNotNull(dynamic_cast<TForm *>(Sender)));
+  if (Sender != NULL)
+  {
+    EditorFormFileUploadComplete(DebugNotNull(dynamic_cast<TForm *>(Sender)));
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RemoteDirViewEnter(TObject * /*Sender*/)

+ 1 - 1
source/forms/CustomScpExplorer.h

@@ -464,7 +464,7 @@ protected:
   void __fastcall ExecutedFileReload(const UnicodeString & FileName, TEditedFileData * Data);
   void __fastcall ExecutedFileEarlyClosed(const TEditedFileData * Data,
     bool & KeepOpen);
-  void __fastcall ExecutedFileUploadComplete(TEditedFileData * Data, TObject * Sender);
+  void __fastcall ExecutedFileUploadComplete(TEditedFileData * Data, TObject * Sender, bool Failed);
   bool EditorCheckNotModified(const TEditedFileData * Data);
   void __fastcall CMDialogChar(TMessage & AMessage);
   inline void __fastcall WMAppCommand(TMessage & Message);

+ 6 - 6
source/windows/EditorManager.cpp

@@ -297,7 +297,7 @@ void __fastcall TEditorManager::Check()
 
       if (Index >= 0)
       {
-        UploadComplete(Index);
+        UploadComplete(Index, false); // To be improved: do not know if it really succeeded
       }
     }
     while ((Index >= 0) && (FUploadCompleteEvents.size() > 0));
@@ -379,7 +379,7 @@ void __fastcall TEditorManager::AddFile(TFileData & FileData, TEditedFileData *
   Data.release(); // ownership passed
 }
 //---------------------------------------------------------------------------
-void __fastcall TEditorManager::UploadComplete(int Index)
+void __fastcall TEditorManager::UploadComplete(int Index, bool Failed)
 {
   TFileData * FileData = &FFiles[Index];
 
@@ -401,9 +401,9 @@ void __fastcall TEditorManager::UploadComplete(int Index)
       FileData->Reupload = false;
       CheckFileChange(Index, true);
     }
-    else if ((FileData->Token != NULL) && (FOnFileUploadComplete != NULL))
+    else if (FOnFileUploadComplete != NULL)
     {
-      FOnFileUploadComplete(FileData->Data, FileData->Token);
+      FOnFileUploadComplete(FileData->Data, FileData->Token, Failed);
     }
   }
 }
@@ -549,7 +549,7 @@ void __fastcall TEditorManager::CheckFileChange(int Index, bool Force)
           OnFileChange(FileData->FileName, FileData->Data, FileData->UploadCompleteEvent, Retry);
           if (Retry)
           {
-            UploadComplete(Index);
+            UploadComplete(Index, true);
             FileData->Timestamp = PrevTimestamp;
           }
         }
@@ -558,7 +558,7 @@ void __fastcall TEditorManager::CheckFileChange(int Index, bool Force)
           // upload failed (was not even started)
           if (FileData->UploadCompleteEvent != INVALID_HANDLE_VALUE)
           {
-            UploadComplete(Index);
+            UploadComplete(Index, true);
           }
           throw;
         }

+ 2 - 2
source/windows/EditorManager.h

@@ -31,7 +31,7 @@ typedef void __fastcall (__closure * TEditedFileReloadEvent)
 typedef void __fastcall (__closure * TEditedFileEarlyClosedEvent)
   (const TEditedFileData * Data, bool & KeepOpen);
 typedef void __fastcall (__closure * TEditedFileUploadComplete)
-  (TEditedFileData * Data, TObject * Token);
+  (TEditedFileData * Data, TObject * Token, bool Failed);
 //---------------------------------------------------------------------------
 typedef void __fastcall (__closure * TEditedFileProcessEvent)
   (const UnicodeString FileName, TEditedFileData * Data, TObject * Token, void * Arg);
@@ -94,7 +94,7 @@ private:
   TEditedFileUploadComplete FOnFileUploadComplete;
 
   void __fastcall AddFile(TFileData & FileData, TEditedFileData * Data);
-  void __fastcall UploadComplete(int Index);
+  void __fastcall UploadComplete(int Index, bool Failed);
   bool __fastcall CloseFile(int Index, bool IgnoreErrors, bool Delete);
   void __fastcall CloseProcess(int Index);
   bool __fastcall EarlyClose(int Index);