浏览代码

Ignore attempts to directly move/duplicate file over itself, as if protocol requires deleting, the file would be lost

Source commit: 0a3fb92c74e25dfc9d99ea868f03a50a5c8586ec
Martin Prikryl 1 年之前
父节点
当前提交
aa964c3fd2
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      source/core/Terminal.cpp

+ 7 - 2
source/core/Terminal.cpp

@@ -4834,11 +4834,17 @@ bool TTerminal::DoRenameOrCopyFile(
   bool Move, bool DontOverwrite, bool IsBatchOperation)
 {
   TBatchOverwrite BatchOverwrite = (IsBatchOperation ? OperationProgress->BatchOverwrite : boNo);
+  UnicodeString AbsoluteFileName = AbsolutePath(FileName, true);
   UnicodeString AbsoluteNewName = AbsolutePath(NewName, true);
   bool Result = true;
   bool ExistenceKnown = false;
   std::unique_ptr<TRemoteFile> DuplicateFile;
-  if (BatchOverwrite == boNone)
+  if (UnixSamePath(AbsoluteFileName, AbsoluteNewName))
+  {
+    LogEvent(FORMAT(L"Tartget \"%s\" is same as source \"%s\" - skipping.", (AbsoluteNewName, AbsoluteFileName)));
+    Result = false;
+  }
+  else if (BatchOverwrite == boNone)
   {
     DebugAssert(!DontOverwrite); // unsupported combination
     Result = !FileExists(AbsoluteNewName);
@@ -4959,7 +4965,6 @@ bool TTerminal::DoRenameOrCopyFile(
       TRetryOperationLoop RetryLoop(this);
       do
       {
-        UnicodeString AbsoluteFileName = AbsolutePath(FileName, true);
         DebugAssert(FileSystem != NULL);
         if (Rename)
         {