Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure available packages match with a single installed package #1473

Merged
merged 4 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,17 +641,14 @@ namespace AppInstaller::CLI::Workflow
}

// Report dependencies
DependencyList allDependencies;
for (auto package : context.Get<Execution::Data::PackagesToInstall>())
if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Dependencies))
{
if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Dependencies))
DependencyList allDependencies;
for (auto package : context.Get<Execution::Data::PackagesToInstall>())
{
allDependencies.Add(package.Installer.Dependencies);
}
}

if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Dependencies))
{
context.Add<Execution::Data::Dependencies>(allDependencies);
context << Workflow::ReportDependencies(m_dependenciesReportMessage);
}
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/WorkflowBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Expand Down
36 changes: 32 additions & 4 deletions src/AppInstallerRepositoryCore/CompositeSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,42 @@ namespace AppInstaller::Repository

SearchResult installedCrossRef = m_installedSource->Search(systemReferenceSearch);

for (auto&& crossRef : installedCrossRef.Matches)
std::shared_ptr<IPackage> 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<CompositePackage>(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 && !result.ContainsInstalledPackage(installedPackage.get()))
{
foundInstalledMatch = true;
florelis marked this conversation as resolved.
Show resolved Hide resolved
result.Matches.emplace_back(std::make_shared<CompositePackage>(std::move(installedPackage), std::move(match.Package)), match.MatchCriteria);
}
}

// If there was no correlation for this package, add it without one.
Expand Down