From e2732c07a833f2fd3bfe38a285202f4f0d501abd Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 25 Jul 2013 22:52:09 +0200 Subject: [PATCH] Fix 'package extract' with multiple explicit entries * before adding a child to a parent entry, we need to check if the parent already contains that child, as otherwise duplicate children with identical names would be added, which in turn messes up the handling of the entries that are to be extracted --- src/bin/package/command_extract.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bin/package/command_extract.cpp b/src/bin/package/command_extract.cpp index 41d7fb821f..4c083dca0e 100644 --- a/src/bin/package/command_extract.cpp +++ b/src/bin/package/command_extract.cpp @@ -185,6 +185,14 @@ struct Entry { static status_t Create(Entry* parent, const char* name, bool implicit, Entry*& _entry) { + if (parent != NULL) { + Entry* entryInParent = parent->FindChild(name); + if (entryInParent != NULL) { + _entry = entryInParent; + return B_OK; + } + } + char* clonedName = strdup(name); if (clonedName == NULL) return B_NO_MEMORY; @@ -804,7 +812,6 @@ do_extract(const char* packageFileName, const char* changeToDirectory, entryName); exit(1); } - if (handler.AddFilterEntry(entryName) != B_OK) exit(1); } @@ -836,6 +843,7 @@ do_extract(const char* packageFileName, const char* changeToDirectory, // check whether all explicitly specified entries have been extracted if (explicitEntryCount > 0) { for (int i = 0; i < explicitEntryCount; i++) { + printf("check...en:%s\n", explicitEntries[i]); if (Entry* entry = handler.FindFilterEntry(explicitEntries[i])) { if (!entry->Seen()) { fprintf(stderr, "Warning: Entry \"%s\" not found.\n", @@ -893,7 +901,6 @@ command_extract(int argc, const char* const* argv) const char* packageFileName = argv[optind++]; const char* const* explicitEntries = argv + optind; int explicitEntryCount = argc - optind; - do_extract(packageFileName, changeToDirectory, packageInfoFileName, explicitEntries, explicitEntryCount, true); do_extract(packageFileName, changeToDirectory,