Skip to content
Open
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
28 changes: 20 additions & 8 deletions src/microsoft-update-partition/Metadata/UpdateBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,29 @@ public string Description
{
get
{
if (_MetadataLoaded)
if (_DescriptionLoaded)
{
return _Description;
}
else
{
LoadNonIndexedMetadataBase();
return _Description;
}
}
else if (_FastLookupSource != null)
{
_FastLookupSource.TrySimpleKeyLookup<string>(_Id, Storage.Index.AvailableIndexes.DescriptionsIndexName, out string description);
return description;
}
else if (_MetadataSource != null)
{
LoadNonIndexedMetadataBase();
_DescriptionLoaded = true;
return _Description;
}
else
{
return null;
}
}
}
private string _Description = null;
private bool _DescriptionLoaded;
private string _Description = null;

/// <summary>
/// Gets the list of files (content) for update
Expand Down Expand Up @@ -464,6 +475,7 @@ internal MicrosoftUpdatePackage(MicrosoftUpdatePackageIdentity id, XPathNavigato
_TitleLoaded = true;

_Description = UpdateParser.GetDescription(metadataNavigator, namespaceManager);
_DescriptionLoaded = true;
_MetadataLoaded = true;

_Prerequisites = PrerequisiteParser.FromXml(metadataNavigator, namespaceManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PartitionRegistration
{
Factory = null,
HasExternalContentFileMetadata = false,
Indexes = new List<IndexDefinition>() { TitlesIndex.TitlesIndexDefinition },
Indexes = new List<IndexDefinition>() { TitlesIndex.TitlesIndexDefinition, DescriptionsIndex.DescriptionsIndexDefinition },
HandlesIdentities = false,
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.PackageGraph.ObjectModel;

namespace Microsoft.PackageGraph.Storage.Index
{
class DescriptionsIndex : SimpleIndex<int, string>, ISimpleMetadataIndex<int, string>
{
internal static readonly IndexDefinition DescriptionsIndexDefinition =
new()
{
Name = AvailableIndexes.DescriptionsIndexName,
PartitionName = null,
Version = DescriptionsIndex.CurrentVersion,
Factory = new InternalIndexFactory(),
Tag = "stream"
};

public override IndexDefinition Definition => DescriptionsIndexDefinition;

public DescriptionsIndex(IIndexContainer container) : base(container, AvailableIndexes.TitlesIndexName)
{
}

public override void IndexPackage(IPackage package, int packageIndex)
{
Add(packageIndex, package.Description);
}

public new bool TryGet(int packageIndex, out string description)
{
return base.TryGet(packageIndex, out description);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Microsoft.PackageGraph.Storage.Index
abstract class AvailableIndexes
{
public const string TitlesIndexName = "titles";
public const string DescriptionsIndexName = "descriptions";
}

class InternalIndexFactory : IIndexFactory
Expand All @@ -17,6 +18,7 @@ public IIndex CreateIndex(IndexDefinition definition, IIndexContainer container)
return definition.Name switch
{
AvailableIndexes.TitlesIndexName => new TitlesIndex(container),
AvailableIndexes.DescriptionsIndexName => new DescriptionsIndex(container),
_ => throw new NotImplementedException(),
};
}
Expand Down