From 5e96a5c44c3c78a901d77297517fa4842a297eb9 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 8 Dec 2019 22:51:49 +0100 Subject: Windows: enhancements to the mechanism preserving file timestamps, especially for keyfiles. --- src/Mount/Mount.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/Mount') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 54dc8158..9130eaee 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -10861,6 +10861,21 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) nStatus = ERR_OS_ERROR; goto error; } + else if (!bDevice && bPreserveTimestamp) + { + // ensure that Last Access timestamp is not modified + ftLastAccessTime.dwHighDateTime = 0xFFFFFFFF; + ftLastAccessTime.dwLowDateTime = 0xFFFFFFFF; + + SetFileTime (dev, NULL, &ftLastAccessTime, NULL); + + /* Remember the container modification/creation date and time. */ + + if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0) + bTimeStampValid = FALSE; + else + bTimeStampValid = TRUE; + } // Determine volume host size if (bDevice) @@ -10931,15 +10946,6 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) hostSize = fileSize.QuadPart; } - if (!bDevice && bPreserveTimestamp) - { - /* Remember the container modification/creation date and time. */ - - if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0) - bTimeStampValid = FALSE; - else - bTimeStampValid = TRUE; - } /* Read the volume header from the backup file */ char buffer[TC_VOLUME_HEADER_GROUP_SIZE]; -- cgit v1.2.3