Browse Source

Bug 1496: While downloading, when an SSH_FXP_FSTAT response does not include timestamps, using known timestamps from directory listing for a local file

https://winscp.net/tracker/1496

Source commit: e09dd8a6b90ac33caca49afdfd3f1262b5b4d10a
Martin Prikryl 8 years ago
parent
commit
28b6b8c7d8
1 changed files with 8 additions and 18 deletions
  1. 8 18
      source/core/SftpFileSystem.cpp

+ 8 - 18
source/core/SftpFileSystem.cpp

@@ -720,10 +720,6 @@ public:
           GetCardinal(); // skip access time subseconds
         }
       }
-      else
-      {
-        File->LastAccess = Now();
-      }
       if (Flags & SSH_FILEXFER_ATTR_CREATETIME)
       {
         GetInt64(); // skip create time
@@ -740,10 +736,6 @@ public:
           GetCardinal(); // skip modification time subseconds
         }
       }
-      else
-      {
-        File->Modification = Now();
-      }
       // SFTP-6
       if (Flags & SSH_FILEXFER_ATTR_CTIME)
       {
@@ -5758,7 +5750,7 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName,
       ReceiveResponse(&RemoteFilePacket, &RemoteFilePacket);
       OperationProgress->Progress();
 
-      const TRemoteFile * AFile = File;
+      const TRemoteFile * AFile = NULL;
       try
       {
         // ignore errors
@@ -5769,18 +5761,16 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName,
             NULL, false);
         }
 
-        Modification = AFile->Modification;
-        AcTime = DateTimeToFileTime(AFile->LastAccess,
-          FTerminal->SessionData->DSTMode);
-        WrTime = DateTimeToFileTime(Modification,
-          FTerminal->SessionData->DSTMode);
+        Modification =
+          (AFile != NULL) && (AFile->Modification != TDateTime()) ? AFile->Modification : File->Modification;
+        TDateTime LastAccess =
+          (AFile != NULL) && (AFile->LastAccess != TDateTime()) ? AFile->LastAccess : File->LastAccess;
+        AcTime = DateTimeToFileTime(LastAccess, FTerminal->SessionData->DSTMode);
+        WrTime = DateTimeToFileTime(Modification, FTerminal->SessionData->DSTMode);
       }
       __finally
       {
-        if (AFile != File)
-        {
-          delete AFile;
-        }
+        delete AFile;
       }
 
       if ((Attrs >= 0) && !ResumeTransfer)