a descent catalog index /catalog
This commit is contained in:
parent
4f040be236
commit
ca079e1c47
4 changed files with 50 additions and 81 deletions
|
|
@ -31,10 +31,10 @@ namespace isnd.Data.Catalog
|
|||
Bid = bid;
|
||||
Parent = Bid + $"/{pkgid}/index.json";
|
||||
DlBase = dlBase;
|
||||
this.items = new List<PackageVersion>(items);
|
||||
this.items = new List<PackageVersion>();
|
||||
this.Id = Bid + "/" + pkgid + "/index.json";
|
||||
this.pkgid = pkgid;
|
||||
UpdateCompact();
|
||||
AddVersionRange(items);
|
||||
}
|
||||
|
||||
public string GetPackageId()
|
||||
|
|
@ -42,28 +42,6 @@ namespace isnd.Data.Catalog
|
|||
return pkgid;
|
||||
}
|
||||
|
||||
private void UpdateCompact()
|
||||
{
|
||||
NuGetVersion upper = new NuGetVersion(0,0,0);
|
||||
|
||||
// Assert.True(items.All(p=>p.Id == id));
|
||||
long commitMax = 0;
|
||||
foreach (var p in items)
|
||||
{
|
||||
if (upper < p.NugetVersion) upper = p.NugetVersion;
|
||||
}
|
||||
Upper = upper.ToFullString();
|
||||
NuGetVersion lower = upper;
|
||||
foreach (var p in items)
|
||||
{
|
||||
if (lower > p.NugetVersion) lower = p.NugetVersion;
|
||||
if (p.CommitNId>commitMax) commitMax = p.CommitNId;
|
||||
}
|
||||
Lower = lower.ToFullString();
|
||||
Count = items.Count;
|
||||
CommitId = commitMax.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// no The array of registration leaves and their associate metadata
|
||||
/// </summary>
|
||||
|
|
@ -75,9 +53,27 @@ namespace isnd.Data.Catalog
|
|||
public void AddVersionRange(IEnumerable<PackageVersion> vitems)
|
||||
{
|
||||
if (vitems.Count() == 0) return;
|
||||
items.AddRange(vitems);
|
||||
UpdateCompact();
|
||||
NuGetVersion upper = null;
|
||||
NuGetVersion lower = null;
|
||||
if (Lower!=null) lower = new NuGetVersion(Lower);
|
||||
if (Upper!=null) upper = new NuGetVersion(Upper);
|
||||
|
||||
// Assert.True(items.All(p=>p.Id == id));
|
||||
long commitMax = 0;
|
||||
foreach (var p in vitems)
|
||||
{
|
||||
if (items.Contains(p))
|
||||
continue;
|
||||
if (upper == null || upper < p.NugetVersion) upper = p.NugetVersion;
|
||||
if (lower == null || lower > p.NugetVersion) lower = p.NugetVersion;
|
||||
if (p.CommitNId> commitMax) commitMax = p.CommitNId;
|
||||
items.Add(p);
|
||||
}
|
||||
Upper = upper.ToFullString();
|
||||
Lower = lower.ToFullString();
|
||||
CommitId = commitMax.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The highest SemVer 2.0.0 version in the page (inclusive)
|
||||
/// </summary>
|
||||
|
|
@ -99,7 +95,7 @@ namespace isnd.Data.Catalog
|
|||
public string Parent { get; set; }
|
||||
|
||||
[JsonProperty("count")]
|
||||
public int Count { get; internal set; }
|
||||
public int Count { get => items.Count; }
|
||||
public string CommitId { get; internal set; }
|
||||
public DateTime CommitTimeStamp { get; internal set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue