From 0cc9a12ae024ac4894a9deb58b2ee6968c7053ff Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Thu, 7 May 2020 21:25:18 +0100 Subject: [PATCH] Installer: fix an issue where file attributes were not copied The issue was introduced when the original CopyFile() and CopyFolder() methods were integrated into a single recursive Copy() method in bf551d3889bfdce1e2250df307d505d88fe6c4e1 The installer originally followed the principle that attributes are not copied for target directories that already exist. Unfortunately the new logic to filter out that case disables attribute copying in recursive calls of this method, thus breaking things like bookmarks and tracker templates. Fixes #15913 Change-Id: I0dfe5ce30fdc78cfd4e3695b4b4e8c23b4848100 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2600 Reviewed-by: Adrien Destugues Reviewed-by: leorize --- src/apps/installer/CopyEngine.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/apps/installer/CopyEngine.cpp b/src/apps/installer/CopyEngine.cpp index b0b1286645..225bd90e8f 100644 --- a/src/apps/installer/CopyEngine.cpp +++ b/src/apps/installer/CopyEngine.cpp @@ -329,6 +329,11 @@ CopyEngine::_Copy(BEntry &source, BEntry &destination, if (cancelSemaphore >= 0) lock.Unlock(); + bool copyAttributesToTarget = copyAttributes; + // attributes of the current source to the destination will be copied + // when copyAttributes is set to true, but there may be exceptions, so + // allow the recursively used copyAttribute parameter to be overridden + // for the current target. if (S_ISDIR(sourceInfo.st_mode)) { BDirectory sourceDirectory(&source); ret = sourceDirectory.InitCheck(); @@ -345,7 +350,7 @@ CopyEngine::_Copy(BEntry &source, BEntry &destination, // Do not overwrite attributes on folders that exist. // This should work better when the install target // already contains a Haiku installation. - copyAttributes = false; + copyAttributesToTarget = false; } } else { ret = destination.Remove(); @@ -431,8 +436,8 @@ CopyEngine::_Copy(BEntry &source, BEntry &destination, } } - if (copyAttributes) { - // copy attributes + if (copyAttributesToTarget) { + // copy attributes to the current target BNode sourceNode(&source); BNode targetNode(&destination); char attrName[B_ATTR_NAME_LENGTH];