فهرست منبع

Bug 1728: Reloading file in internal editor can cause unwanted upload of partially reloaded file

https://winscp.net/tracker/1728

Source commit: 1b0c64e2989b778e71321054ab378a9035bd3e29
Martin Prikryl 6 سال پیش
والد
کامیت
cefb3bda8c
2فایلهای تغییر یافته به همراه14 افزوده شده و 2 حذف شده
  1. 13 2
      source/windows/EditorManager.cpp
  2. 1 0
      source/windows/EditorManager.h

+ 13 - 2
source/windows/EditorManager.cpp

@@ -339,6 +339,7 @@ void __fastcall TEditorManager::FileReload(TObject * Token)
   DebugAssert(Index >= 0);
   TFileData * FileData = &FFiles[Index];
   DebugAssert(!FileData->External);
+  TAutoFlag ReloadingFlag(FileData->Reloading);
 
   OnFileReload(FileData->FileName, FileData->Data);
   FileAge(FileData->FileName, FileData->Timestamp);
@@ -364,6 +365,7 @@ void __fastcall TEditorManager::AddFile(TFileData & FileData, TEditedFileData *
   FileData.UploadCompleteEvent = INVALID_HANDLE_VALUE;
   FileData.Opened = Now();
   FileData.Reupload = false;
+  FileData.Reloading = false;
   FileData.Saves = 0;
   FileData.Data = Data.get();
 
@@ -455,8 +457,17 @@ bool __fastcall TEditorManager::CloseFile(int Index, bool IgnoreErrors, bool Del
 bool __fastcall TEditorManager::HasFileChanged(int Index, TDateTime & NewTimestamp)
 {
   TFileData * FileData = &FFiles[Index];
-  FileAge(FileData->FileName, NewTimestamp);
-  return (FileData->Timestamp != NewTimestamp);
+  bool Result;
+  if (FileData->Reloading)
+  {
+    Result = false;
+  }
+  else
+  {
+    FileAge(FileData->FileName, NewTimestamp);
+    Result = (FileData->Timestamp != NewTimestamp);
+  }
+  return Result;
 }
 //---------------------------------------------------------------------------
 void __fastcall TEditorManager::CheckFileChange(int Index, bool Force)

+ 1 - 0
source/windows/EditorManager.h

@@ -80,6 +80,7 @@ private:
     HANDLE UploadCompleteEvent;
     TDateTime Opened;
     bool Reupload;
+    bool Reloading;
     unsigned int Saves;
   };