commit e583f91512638da6edb815ab2fe1f4cc845b0ed1
parent fbb11c13f95da43a03a0f50d78fa9aead2c00862
Author: yao-msft <50888816+yao-msft@users.noreply.github.com>
Date: Thu, 15 Sep 2022 15:30:23 -0700
Fix installer metadata collection (#2517)
Diffstat:
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/AppInstallerRepositoryCore/InstallerMetadataCollectionContext.cpp b/src/AppInstallerRepositoryCore/InstallerMetadataCollectionContext.cpp
@@ -489,7 +489,11 @@ namespace AppInstaller::Repository::Metadata
AICLI_LOG(Repo, Info, << "Opening InstallerMetadataCollectionContext input file: " << file);
std::ifstream fileStream{ file };
- result->InitializePreinstallState(ConvertToUTF16(ReadEntireStream(fileStream)));
+ auto content = ReadEntireStream(fileStream);
+ // CppRestSdk's implementation of json parsing does not work with '\0', so trimming them here
+ content.erase(std::find(content.begin(), content.end(), '\0'), content.end());
+
+ result->InitializePreinstallState(ConvertToUTF16(content));
return result;
}
diff --git a/src/AppInstallerRepositoryCore/RepositorySource.cpp b/src/AppInstallerRepositoryCore/RepositorySource.cpp
@@ -498,7 +498,7 @@ namespace AppInstaller::Repository
if (!m_source)
{
- SourceList sourceList;
+ std::unique_ptr<SourceList> sourceList;
// Check for updates before opening.
for (auto& sourceReference : m_sourceReferences)
@@ -512,9 +512,14 @@ namespace AppInstaller::Repository
// to avoid the progress bar fill up multiple times.
if (BackgroundUpdateSourceFromDetails(details, progress))
{
- auto detailsInternal = sourceList.GetSource(details.Name);
+ if (sourceList == nullptr)
+ {
+ sourceList = std::make_unique<SourceList>();
+ }
+
+ auto detailsInternal = sourceList->GetSource(details.Name);
detailsInternal->LastUpdateTime = details.LastUpdateTime;
- sourceList.SaveMetadata(*detailsInternal);
+ sourceList->SaveMetadata(*detailsInternal);
}
else
{