[FarGroup/FarManager] master: Preserve timestamps for existing destination directories (8cdeacd88)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Jan 31, 2026, 11:45:59 AM (6 days ago) Jan 31
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/8cdeacd88b02f2ac2338b1ab65eb9ea748e82f29

>---------------------------------------------------------------

commit 8cdeacd88b02f2ac2338b1ab65eb9ea748e82f29
Author: Artem S. Tashkinov <birdie...@users.noreply.github.com>
Date: Sat Jan 31 16:28:37 2026 +0000

Preserve timestamps for existing destination directories

When copying or moving directories with "Preserve all timestamps" enabled, timestamps are restored only for newly created destination directories.

If the destination directory already exists, its timestamps are currently left unchanged, even when it corresponds to a source directory being copied. This breaks the expected behavior of the option.

Queue existing destination directories for timestamp restoration in the same way as newly created ones, so their timestamps are restored after copy completion.

Fixes #460


>---------------------------------------------------------------

8cdeacd88b02f2ac2338b1ab65eb9ea748e82f29
far/changelog | 5 +++++
far/copy.cpp | 9 +++++++++
far/vbuild.m4 | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/far/changelog b/far/changelog
index 687a7a42f..4f3a5ffe8 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,8 @@
+--------------------------------------------------------------------------------
+birdie-github 2026-01-31 16:27:32+00:00 - build 6640
+
+1. gh-1059: Preserve timestamps for existing destination directories.
+
--------------------------------------------------------------------------------
drkns 2026-01-30 20:00:26+00:00 - build 6639

diff --git a/far/copy.cpp b/far/copy.cpp
index f22ec7255..1649335ba 100644
--- a/far/copy.cpp
+++ b/far/copy.cpp
@@ -1982,6 +1982,15 @@ COPY_CODES ShellCopy::ShellCopyOneFile(
{
if ((DestAttr & FILE_ATTRIBUTE_DIRECTORY) && !SameName)
{
+ // The destination directory already exists.
+ // When "Preserve all timestamps" is enabled we still want to restore
+ // the source directory timestamps after the copy is finished.
+ //
+ // Setting timestamps here would be pointless: the subsequent copy of
+ // files into the directory will update its times again.
+ if (Global->Opt->CMOpt.PreserveTimestamps)
+ m_CreatedFolders.emplace_back(strDestPath, SrcData);
+
auto SetAttr = SrcData.Attributes;

if (SrcDriveType == DRIVE_CDROM && (SetAttr & FILE_ATTRIBUTE_READONLY))
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index 257506515..28d2ab292 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6639
+6640


Reply all
Reply to author
Forward
0 new messages