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
bf551d3889

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 <pulkomandy@gmail.com>
Reviewed-by: leorize <leorize+oss@disroot.org>
This commit is contained in:
Niels Sascha Reedijk 2020-05-07 21:25:18 +01:00
parent 362f1bd35b
commit 0cc9a12ae0
1 changed files with 8 additions and 3 deletions

View File

@ -329,6 +329,11 @@ CopyEngine::_Copy(BEntry &source, BEntry &destination,
if (cancelSemaphore >= 0) if (cancelSemaphore >= 0)
lock.Unlock(); 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)) { if (S_ISDIR(sourceInfo.st_mode)) {
BDirectory sourceDirectory(&source); BDirectory sourceDirectory(&source);
ret = sourceDirectory.InitCheck(); ret = sourceDirectory.InitCheck();
@ -345,7 +350,7 @@ CopyEngine::_Copy(BEntry &source, BEntry &destination,
// Do not overwrite attributes on folders that exist. // Do not overwrite attributes on folders that exist.
// This should work better when the install target // This should work better when the install target
// already contains a Haiku installation. // already contains a Haiku installation.
copyAttributes = false; copyAttributesToTarget = false;
} }
} else { } else {
ret = destination.Remove(); ret = destination.Remove();
@ -431,8 +436,8 @@ CopyEngine::_Copy(BEntry &source, BEntry &destination,
} }
} }
if (copyAttributes) { if (copyAttributesToTarget) {
// copy attributes // copy attributes to the current target
BNode sourceNode(&source); BNode sourceNode(&source);
BNode targetNode(&destination); BNode targetNode(&destination);
char attrName[B_ATTR_NAME_LENGTH]; char attrName[B_ATTR_NAME_LENGTH];