浏览代码

Bug 1790: Error when reopening a remote file whose local temporary copy has been deleted

https://winscp.net/tracker/1790

Source commit: 1626f24c5cd9ced9b4d3e36bc53868f63b887794
Martin Prikryl 6 年之前
父节点
当前提交
9fbbf45745
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      source/windows/EditorManager.cpp

+ 8 - 3
source/windows/EditorManager.cpp

@@ -116,9 +116,14 @@ bool __fastcall TEditorManager::CanAddFile(const UnicodeString RemoteDirectory,
           }
           else
           {
-            // get directory where the file already is so we download it there again
-            ExistingLocalRootDirectory = FileData->Data->LocalRootDirectory;
-            ExistingLocalDirectory = ExtractFilePath(FileData->FileName);
+            UnicodeString AExistingLocalDirectory = ExtractFilePath(FileData->FileName);
+            // If the temporary directory was deleted, behave like the file was never opened
+            if (DirectoryExists(AExistingLocalDirectory))
+            {
+              // get directory where the file already is so we download it there again
+              ExistingLocalRootDirectory = FileData->Data->LocalRootDirectory;
+              ExistingLocalDirectory = AExistingLocalDirectory;
+            }
             CloseFile(i, false, false); // do not delete file
             Result = true;
           }