commit 2cfe7865ee064a6710ae689308ae8c210fe105fd
parent fd3597da06a74dcb444b9814515242577bf9d174
Author: JohnMcPMS <johnmcp@microsoft.com>
Date: Thu, 28 Sep 2023 13:41:25 -0700
Revert "Enable COM API access to correlate with the tracking database only (#3670)" (#3700)
This reverts commit c255b68a652c59370a2ee9348a9ef36aa18ea1d3.
Diffstat:
6 files changed, 30 insertions(+), 129 deletions(-)
diff --git a/src/AppInstallerRepositoryCore/CompositeSource.cpp b/src/AppInstallerRepositoryCore/CompositeSource.cpp
@@ -1412,12 +1412,15 @@ namespace AppInstaller::Repository
}
}
+ bool addedAvailablePackage = false;
+
// Directly search for the available package from tracking information.
if (trackingPackage)
{
auto availablePackage = GetTrackedPackageFromAvailableSource(result, trackedSource, trackingPackage->GetProperty(PackageProperty::Id));
if (availablePackage)
{
+ addedAvailablePackage = true;
compositePackage->AddAvailablePackage(std::move(availablePackage));
}
compositePackage->SetTracking(std::move(trackedSource), std::move(trackingPackage), std::move(trackingPackageVersion));
@@ -1450,6 +1453,7 @@ namespace AppInstaller::Repository
});
// For non pinning cases. We found some matching packages here, don't keep going.
+ addedAvailablePackage = true;
compositePackage->AddAvailablePackage(std::move(availablePackage));
}
}
diff --git a/src/AppInstallerRepositoryCore/Public/winget/RepositorySource.h b/src/AppInstallerRepositoryCore/Public/winget/RepositorySource.h
@@ -225,10 +225,6 @@ namespace AppInstaller::Repository
// Set background update check interval.
void SetBackgroundUpdateInterval(TimeSpan interval);
- // Indicates that we are only interested in the PackageTrackingCatalog for the source.
- // Must be set before Open to have effect, and will prevent the underlying source from being updated or opened.
- void InstalledPackageInformationOnly(bool value);
-
// Execute a search on the source.
SearchResult Search(const SearchRequest& request) const;
@@ -291,7 +287,6 @@ namespace AppInstaller::Repository
bool m_isSourceToBeAdded = false;
bool m_isComposite = false;
std::optional<TimeSpan> m_backgroundUpdateInterval;
- bool m_installedPackageInformationOnly = false;
mutable PackageTrackingCatalog m_trackingCatalog;
};
}
diff --git a/src/AppInstallerRepositoryCore/RepositorySource.cpp b/src/AppInstallerRepositoryCore/RepositorySource.cpp
@@ -202,53 +202,6 @@ namespace AppInstaller::Repository
SourceDetails m_details;
std::exception_ptr m_exception;
};
-
- // A wrapper that doesn't actually forward the search requests.
- struct TrackingOnlySourceWrapper : public ISource
- {
- TrackingOnlySourceWrapper(std::shared_ptr<ISourceReference> wrapped) : m_wrapped(std::move(wrapped))
- {
- m_identifier = m_wrapped->GetIdentifier();
- }
-
- const std::string& GetIdentifier() const override { return m_identifier; }
-
- SourceDetails& GetDetails() const override { return m_wrapped->GetDetails(); }
-
- SourceInformation GetInformation() const override { return m_wrapped->GetInformation(); }
-
- SearchResult Search(const SearchRequest&) const override { return {}; }
-
- void* CastTo(ISourceType) override { return nullptr; }
-
- private:
- std::shared_ptr<ISourceReference> m_wrapped;
- std::string m_identifier;
- };
-
- // A wrapper to create another wrapper.
- struct TrackingOnlyReferenceWrapper : public ISourceReference
- {
- TrackingOnlyReferenceWrapper(std::shared_ptr<ISourceReference> wrapped) : m_wrapped(std::move(wrapped)) {}
-
- std::string GetIdentifier() override { return m_wrapped->GetIdentifier(); }
-
- SourceDetails& GetDetails() override { return m_wrapped->GetDetails(); }
-
- SourceInformation GetInformation() override { return m_wrapped->GetInformation(); }
-
- bool SetCustomHeader(std::optional<std::string>) override { return false; }
-
- void SetCaller(std::string caller) override { m_wrapped->SetCaller(std::move(caller)); }
-
- std::shared_ptr<ISource> Open(IProgressCallback&) override
- {
- return std::make_shared<TrackingOnlySourceWrapper>(m_wrapped);
- }
-
- private:
- std::shared_ptr<ISourceReference> m_wrapped;
- };
}
std::unique_ptr<ISourceFactory> ISourceFactory::GetForType(std::string_view type)
@@ -522,11 +475,6 @@ namespace AppInstaller::Repository
m_backgroundUpdateInterval = interval;
}
- void Source::InstalledPackageInformationOnly(bool value)
- {
- m_installedPackageInformationOnly = value;
- }
-
SearchResult Source::Search(const SearchRequest& request) const
{
THROW_HR_IF(HRESULT_FROM_WIN32(ERROR_INVALID_STATE), !m_source);
@@ -606,68 +554,51 @@ namespace AppInstaller::Repository
if (!m_source)
{
- std::vector<std::shared_ptr<ISourceReference>>* sourceReferencesToOpen = nullptr;
- std::vector<std::shared_ptr<ISourceReference>> sourceReferencesForTrackingOnly;
std::unique_ptr<SourceList> sourceList;
- if (m_installedPackageInformationOnly)
+ // Check for updates before opening.
+ for (auto& sourceReference : m_sourceReferences)
{
- sourceReferencesToOpen = &sourceReferencesForTrackingOnly;
-
- // Create a wrapper for each reference
- for (auto& sourceReference : m_sourceReferences)
+ auto& details = sourceReference->GetDetails();
+ if (ShouldUpdateBeforeOpen(details, m_backgroundUpdateInterval))
{
- sourceReferencesForTrackingOnly.emplace_back(std::make_shared<TrackingOnlyReferenceWrapper>(sourceReference));
- }
- }
- else
- {
- // Check for updates before opening.
- for (auto& sourceReference : m_sourceReferences)
- {
- auto& details = sourceReference->GetDetails();
- if (ShouldUpdateBeforeOpen(details, m_backgroundUpdateInterval))
+ try
{
- try
+ // TODO: Consider adding a context callback to indicate we are doing the same action
+ // to avoid the progress bar fill up multiple times.
+ if (BackgroundUpdateSourceFromDetails(details, progress))
{
- // TODO: Consider adding a context callback to indicate we are doing the same action
- // to avoid the progress bar fill up multiple times.
- if (BackgroundUpdateSourceFromDetails(details, progress))
- {
- if (sourceList == nullptr)
- {
- sourceList = std::make_unique<SourceList>();
- }
-
- auto detailsInternal = sourceList->GetSource(details.Name);
- detailsInternal->LastUpdateTime = details.LastUpdateTime;
- sourceList->SaveMetadata(*detailsInternal);
- }
- else
+ if (sourceList == nullptr)
{
- AICLI_LOG(Repo, Error, << "Failed to update source: " << details.Name);
- result.emplace_back(details);
+ sourceList = std::make_unique<SourceList>();
}
+
+ auto detailsInternal = sourceList->GetSource(details.Name);
+ detailsInternal->LastUpdateTime = details.LastUpdateTime;
+ sourceList->SaveMetadata(*detailsInternal);
}
- catch (...)
+ else
{
- LOG_CAUGHT_EXCEPTION();
- AICLI_LOG(Repo, Warning, << "Failed to update source: " << details.Name);
+ AICLI_LOG(Repo, Error, << "Failed to update source: " << details.Name);
result.emplace_back(details);
}
}
+ catch (...)
+ {
+ LOG_CAUGHT_EXCEPTION();
+ AICLI_LOG(Repo, Warning, << "Failed to update source: " << details.Name);
+ result.emplace_back(details);
+ }
}
-
- sourceReferencesToOpen = &m_sourceReferences;
}
- if (sourceReferencesToOpen->size() > 1)
+ if (m_sourceReferences.size() > 1)
{
AICLI_LOG(Repo, Info, << "Multiple sources available, creating aggregated source.");
auto aggregatedSource = std::make_shared<CompositeSource>("*DefaultSource");
std::vector<std::shared_ptr<OpenExceptionProxy>> openExceptionProxies;
- for (auto& sourceReference : *sourceReferencesToOpen)
+ for (auto& sourceReference : m_sourceReferences)
{
AICLI_LOG(Repo, Info, << "Adding to aggregated source: " << sourceReference->GetDetails().Name);
@@ -697,7 +628,7 @@ namespace AppInstaller::Repository
}
else
{
- m_source = (*sourceReferencesToOpen)[0]->Open(progress);
+ m_source = m_sourceReferences[0]->Open(progress);
}
}
diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp
@@ -28,7 +28,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation
if (IsBackgroundProcessForPolicy())
{
- // Delay the default update interval for these background processes
static constexpr winrt::Windows::Foundation::TimeSpan s_PackageCatalogUpdateIntervalDelay_Base = 168h; //1 week
// Add a bit of randomness to the default interval time
@@ -36,9 +35,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation
std::uniform_int_distribution<long long> distribution(0, 604800);
m_packageCatalogBackgroundUpdateInterval = s_PackageCatalogUpdateIntervalDelay_Base + std::chrono::seconds(distribution(randomEngine));
-
- // Prevent any update / data processing by default for these background processes
- m_installedPackageInformationOnly = true;
}
}
void PackageCatalogReference::Initialize(winrt::Microsoft::Management::Deployment::CreateCompositePackageCatalogOptions options)
@@ -99,7 +95,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation
auto copy = catalogImpl->m_sourceReference;
copy.SetCaller(callerName);
copy.SetBackgroundUpdateInterval(catalog.PackageCatalogBackgroundUpdateInterval());
- copy.InstalledPackageInformationOnly(catalog.InstalledPackageInformationOnly());
copy.Open(progress);
remoteSources.emplace_back(std::move(copy));
}
@@ -142,7 +137,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation
source = m_sourceReference;
source.SetCaller(callerName);
source.SetBackgroundUpdateInterval(PackageCatalogBackgroundUpdateInterval());
- source.InstalledPackageInformationOnly(m_installedPackageInformationOnly);
source.Open(progress);
}
@@ -222,7 +216,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation
{
return m_acceptSourceAgreements;
}
-
void PackageCatalogReference::PackageCatalogBackgroundUpdateInterval(winrt::Windows::Foundation::TimeSpan const& value)
{
if (IsComposite())
@@ -236,19 +229,4 @@ namespace winrt::Microsoft::Management::Deployment::implementation
{
return m_packageCatalogBackgroundUpdateInterval;
}
-
- bool PackageCatalogReference::InstalledPackageInformationOnly()
- {
- return m_installedPackageInformationOnly;
- }
-
- void PackageCatalogReference::InstalledPackageInformationOnly(bool value)
- {
- if (IsComposite())
- {
- throw winrt::hresult_illegal_state_change();
- }
-
- m_installedPackageInformationOnly = value;
- }
}
diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.h b/src/Microsoft.Management.Deployment/PackageCatalogReference.h
@@ -22,14 +22,12 @@ namespace winrt::Microsoft::Management::Deployment::implementation
winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Management::Deployment::SourceAgreement> SourceAgreements();
hstring AdditionalPackageCatalogArguments();
void AdditionalPackageCatalogArguments(hstring const& value);
- // Contract 6
+ // Contract 6.0
bool AcceptSourceAgreements();
void AcceptSourceAgreements(bool value);
// Contract 8.0
winrt::Windows::Foundation::TimeSpan PackageCatalogBackgroundUpdateInterval();
void PackageCatalogBackgroundUpdateInterval(winrt::Windows::Foundation::TimeSpan const& value);
- bool InstalledPackageInformationOnly();
- void InstalledPackageInformationOnly(bool value);
#if !defined(INCLUDE_ONLY_INTERFACE_METHODS)
private:
@@ -39,7 +37,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation
::AppInstaller::Repository::Source m_sourceReference;
std::optional<std::string> m_additionalPackageCatalogArguments;
bool m_acceptSourceAgreements = true;
- bool m_installedPackageInformationOnly = false;
std::once_flag m_sourceAgreementsOnceFlag;
winrt::Windows::Foundation::TimeSpan m_packageCatalogBackgroundUpdateInterval = winrt::Windows::Foundation::TimeSpan::zero();
#endif
diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl
@@ -754,10 +754,6 @@ namespace Microsoft.Management.Deployment
{
/// Time interval for package catalog to check for an update. Setting to zero will disable the check for update.
Windows.Foundation.TimeSpan PackageCatalogBackgroundUpdateInterval;
-
- // When set to true, the opened catalog will only provide the information regarding packages installed from this catalog.
- // In this mode, no external resources should be required.
- Boolean InstalledPackageInformationOnly;
}
}