From c35dabab37d08f0d3779c6ba38de68bbb475ef83 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Tue, 14 Sep 2021 17:54:37 -0700 Subject: [PATCH 1/4] Check dependencies features only once --- src/AppInstallerCLICore/Workflows/InstallFlow.cpp | 9 +++------ src/AppInstallerCLICore/Workflows/WorkflowBase.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/InstallFlow.cpp b/src/AppInstallerCLICore/Workflows/InstallFlow.cpp index 8f6b17964a..b6ca2db78a 100644 --- a/src/AppInstallerCLICore/Workflows/InstallFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/InstallFlow.cpp @@ -641,17 +641,14 @@ namespace AppInstaller::CLI::Workflow } // Report dependencies - DependencyList allDependencies; - for (auto package : context.Get()) + if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Dependencies)) { - if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Dependencies)) + DependencyList allDependencies; + for (auto package : context.Get()) { allDependencies.Add(package.Installer.Dependencies); } - } - if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Dependencies)) - { context.Add(allDependencies); context << Workflow::ReportDependencies(m_dependenciesReportMessage); } diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.h b/src/AppInstallerCLICore/Workflows/WorkflowBase.h index 2a7a976964..a78170f27d 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.h +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.h @@ -194,7 +194,7 @@ namespace AppInstaller::CLI::Workflow // Ensures that there is only one result in the search. // Required Args: bool indicating if the search result is from installed source // Inputs: SearchResult - // Outputs: None + // Outputs: Package struct EnsureOneMatchFromSearchResult : public WorkflowTask { EnsureOneMatchFromSearchResult(bool isFromInstalledSource) : From f133d287bc2309e62f22193f396f37e788b63ed0 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Tue, 14 Sep 2021 17:55:19 -0700 Subject: [PATCH 2/4] Ensure available packages match with single installed package --- .../CompositeSource.cpp | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/AppInstallerRepositoryCore/CompositeSource.cpp b/src/AppInstallerRepositoryCore/CompositeSource.cpp index 21ec7c1a9a..cc25531fd0 100644 --- a/src/AppInstallerRepositoryCore/CompositeSource.cpp +++ b/src/AppInstallerRepositoryCore/CompositeSource.cpp @@ -553,14 +553,43 @@ namespace AppInstaller::Repository SearchResult installedCrossRef = m_installedSource->Search(systemReferenceSearch); - for (auto&& crossRef : installedCrossRef.Matches) + std::shared_ptr installedPackage; + if (installedCrossRef.Matches.size() == 1) { - if (!result.ContainsInstalledPackage(crossRef.Package.get())) + installedPackage = std::move(installedCrossRef.Matches[0].Package); + } + else if (installedCrossRef.Matches.size() > 1) + { + AICLI_LOG(Repo, Info, + << "Found multiple matches for available package [" << match.Package->GetProperty(PackageProperty::Id) << + "] in source [" << source->GetIdentifier() << "] when searching for [" << systemReferenceSearch.ToString() << "]"); + + // More than one match found for the system reference; run some heuristics to check for a match + for (auto&& crossRef : installedCrossRef.Matches) { - foundInstalledMatch = true; - result.Matches.emplace_back(std::make_shared(std::move(crossRef.Package), std::move(match.Package)), match.MatchCriteria); + AICLI_LOG(Repo, Info, << " Checking match with package id: " << crossRef.Package->GetProperty(PackageProperty::Id)); + + if (IsStrongMatchField(crossRef.MatchCriteria.Field)) + { + if (!installedPackage) + { + installedPackage = std::move(crossRef.Package); + } + else + { + AICLI_LOG(Repo, Info, << " Found multiple packages with strong match fields"); + installedPackage.reset(); + break; + } + } } } + + if (installedPackage) + { + foundInstalledMatch = true; + result.Matches.emplace_back(std::make_shared(std::move(installedPackage), std::move(match.Package)), match.MatchCriteria); + } } // If there was no correlation for this package, add it without one. From 090ac906d5bc882df687c04b0e756174a6231890 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 16 Sep 2021 14:17:52 -0700 Subject: [PATCH 3/4] Add back check for already added package --- .../CompositeSource.cpp | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/AppInstallerRepositoryCore/CompositeSource.cpp b/src/AppInstallerRepositoryCore/CompositeSource.cpp index cc25531fd0..a4e1c65174 100644 --- a/src/AppInstallerRepositoryCore/CompositeSource.cpp +++ b/src/AppInstallerRepositoryCore/CompositeSource.cpp @@ -569,17 +569,20 @@ namespace AppInstaller::Repository { AICLI_LOG(Repo, Info, << " Checking match with package id: " << crossRef.Package->GetProperty(PackageProperty::Id)); - if (IsStrongMatchField(crossRef.MatchCriteria.Field)) + if (!result.ContainsInstalledPackage(crossRef.Package.get())) { - if (!installedPackage) + if (IsStrongMatchField(crossRef.MatchCriteria.Field)) { - installedPackage = std::move(crossRef.Package); - } - else - { - AICLI_LOG(Repo, Info, << " Found multiple packages with strong match fields"); - installedPackage.reset(); - break; + if (!installedPackage) + { + installedPackage = std::move(crossRef.Package); + } + else + { + AICLI_LOG(Repo, Info, << " Found multiple packages with strong match fields"); + installedPackage.reset(); + break; + } } } } From 555d8b7f55b9b55b6c07d2812778e35cdec71ff9 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Tue, 21 Sep 2021 12:19:24 -0700 Subject: [PATCH 4/4] Move check for installed package already correlated --- .../CompositeSource.cpp | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/AppInstallerRepositoryCore/CompositeSource.cpp b/src/AppInstallerRepositoryCore/CompositeSource.cpp index a4e1c65174..35412d39b8 100644 --- a/src/AppInstallerRepositoryCore/CompositeSource.cpp +++ b/src/AppInstallerRepositoryCore/CompositeSource.cpp @@ -568,27 +568,23 @@ namespace AppInstaller::Repository for (auto&& crossRef : installedCrossRef.Matches) { AICLI_LOG(Repo, Info, << " Checking match with package id: " << crossRef.Package->GetProperty(PackageProperty::Id)); - - if (!result.ContainsInstalledPackage(crossRef.Package.get())) + if (IsStrongMatchField(crossRef.MatchCriteria.Field)) { - if (IsStrongMatchField(crossRef.MatchCriteria.Field)) + if (!installedPackage) { - if (!installedPackage) - { - installedPackage = std::move(crossRef.Package); - } - else - { - AICLI_LOG(Repo, Info, << " Found multiple packages with strong match fields"); - installedPackage.reset(); - break; - } + installedPackage = std::move(crossRef.Package); + } + else + { + AICLI_LOG(Repo, Info, << " Found multiple packages with strong match fields"); + installedPackage.reset(); + break; } } } } - if (installedPackage) + if (installedPackage && !result.ContainsInstalledPackage(installedPackage.get())) { foundInstalledMatch = true; result.Matches.emplace_back(std::make_shared(std::move(installedPackage), std::move(match.Package)), match.MatchCriteria);