|
|
@@ -16,6 +16,21 @@ namespace UsmWeb {
|
|
|
public string repo { get; set; default = ""; }
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * One artifact row in a DCBA repository's browse table: the listing
|
|
|
+ * entry's name/version plus the page links the row renders — the
|
|
|
+ * detail page ({@link href}) and the raw `.dcba` download
|
|
|
+ * ({@link download_href}).
|
|
|
+ */
|
|
|
+ public class ArtifactRow : Object {
|
|
|
+ public string name { get; set; default = ""; }
|
|
|
+ public string version { get; set; default = ""; }
|
|
|
+ public string size { get; set; default = ""; }
|
|
|
+ public string file { get; set; default = ""; }
|
|
|
+ public string href { get; set; default = ""; }
|
|
|
+ public string download_href { get; set; default = ""; }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* One repository summary in the overview: the stats card fields plus the
|
|
|
* per-repository add-repository instruction fields ({@link base_uri},
|
|
|
@@ -75,16 +90,20 @@ namespace UsmWeb {
|
|
|
* pre-built artifacts surface in the detail views, never in the
|
|
|
* home package table.
|
|
|
*
|
|
|
- * A repo-scoped build for a DCBA repository throws instead: the
|
|
|
- * package-table state this builder authors does not describe an
|
|
|
- * artifact repository, so the browse entrypoint degrades to its
|
|
|
- * error card for those names (the dedicated DCBA browse view owns
|
|
|
- * that page).
|
|
|
+ * A repo-scoped build for a DCBA repository renders that
|
|
|
+ * repository's browse view instead: the same overview-card
|
|
|
+ * fields (carrying its artifact count and artifact byte total),
|
|
|
+ * the `usm dcba add-repo` instruction and one
|
|
|
+ * {@link ArtifactRow} per `ARTIFACTS.usml` entry. The query
|
|
|
+ * never filters artifacts (search is source-package-only), so
|
|
|
+ * those rows ignore `query` entirely and the page omits the
|
|
|
+ * search form on the DCBA branch.
|
|
|
*/
|
|
|
public static State build(RepositoryService repositories, UsmWebConfig config,
|
|
|
ActionRegistry action_registry, string base_uri, string query, string? repo_name = null) throws Error {
|
|
|
var repo_rows = new Vector<RepoSummary>();
|
|
|
var package_rows = new Vector<PackageRow>();
|
|
|
+ var dcba_artifact_rows = new Vector<ArtifactRow>();
|
|
|
int64 total_bytes = 0;
|
|
|
uint total_count = 0;
|
|
|
uint matched = 0;
|
|
|
@@ -96,16 +115,31 @@ namespace UsmWeb {
|
|
|
}
|
|
|
|
|
|
if (entry.kind == RepositoryKind.DCBA) {
|
|
|
- if (repo_name != null) {
|
|
|
- throw new UsmWebError.INVALID_CONFIGURATION(
|
|
|
- @"Repository \"$repo_name\" is a DCBA artifact repository — its pre-built artifacts are not listed as packages");
|
|
|
- }
|
|
|
-
|
|
|
int64 artifact_bytes = 0;
|
|
|
uint artifact_count = 0;
|
|
|
- foreach (var artifact_entry in entry.dcba_listing_entries()) {
|
|
|
- artifact_bytes += (int64) artifact_entry.size;
|
|
|
- artifact_count++;
|
|
|
+ var artifact_rows = new Vector<ArtifactRow>();
|
|
|
+ if (repo_name != null) {
|
|
|
+ foreach (var artifact_entry in entry.dcba_listing_entries()) {
|
|
|
+ var file = Path.get_basename(artifact_entry.path);
|
|
|
+ artifact_bytes += (int64) artifact_entry.size;
|
|
|
+ artifact_count++;
|
|
|
+ artifact_rows.add(new ArtifactRow() {
|
|
|
+ name = artifact_entry.name,
|
|
|
+ version = artifact_entry.version,
|
|
|
+ size = artifact_entry.size > 0
|
|
|
+ ? format_size((int64) artifact_entry.size)
|
|
|
+ : "?",
|
|
|
+ file = file,
|
|
|
+ href = "/repo/" + repo.name + "/artifact/" + file,
|
|
|
+ download_href = "/repo/" + repo.name + "/" + file
|
|
|
+ });
|
|
|
+ }
|
|
|
+ dcba_artifact_rows.add_all(artifact_rows);
|
|
|
+ } else {
|
|
|
+ foreach (var artifact_entry in entry.dcba_listing_entries()) {
|
|
|
+ artifact_bytes += (int64) artifact_entry.size;
|
|
|
+ artifact_count++;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
repo_rows.add(new RepoSummary() {
|
|
|
@@ -180,13 +214,17 @@ namespace UsmWeb {
|
|
|
var summary = repo_rows.first();
|
|
|
dict.set_native<string>("repo_name", summary.name);
|
|
|
dict.set_native<string>("repo_summary", summary.summary);
|
|
|
+ dict.set_native<string>("repo_kind", summary.kind);
|
|
|
dict.set_native<string>("key_fingerprint", summary.key_fingerprint);
|
|
|
dict.set_native<int>("package_count", summary.package_count);
|
|
|
dict.set_native<string>("total_size", summary.total_size);
|
|
|
dict.set_native<string>("base_uri", summary.base_uri);
|
|
|
dict.set_native<string>("usmr_href", summary.usmr_href);
|
|
|
dict.set_native<string>("repos_d_snippet", summary.repos_d_snippet);
|
|
|
+ dict.set_native<int>("artifact_count", summary.artifact_count);
|
|
|
+ dict.set_native<string>("artifact_total_size", summary.artifact_total_size);
|
|
|
}
|
|
|
+ dict["artifacts"] = artifact_list(dcba_artifact_rows);
|
|
|
dict.set_native<string>("query", query);
|
|
|
dict.set_native<string>("result_note", result_note(query, matched, total_count));
|
|
|
dict.set_native<string>("installer_mode", config.installer.to_string());
|
|
|
@@ -221,6 +259,15 @@ namespace UsmWeb {
|
|
|
return new JsonElement.from_elements(arr);
|
|
|
}
|
|
|
|
|
|
+ /** Builds the artifact rows' JSON array (the same pattern as {@link list}). */
|
|
|
+ public static JsonElement artifact_list(Lot<ArtifactRow> rows) throws Error {
|
|
|
+ var arr = new JsonArray();
|
|
|
+ foreach (var row in rows) {
|
|
|
+ arr.add(new JsonElement.from_properties(GObjectMapping.to_properties(row)));
|
|
|
+ }
|
|
|
+ return new JsonElement.from_elements(arr);
|
|
|
+ }
|
|
|
+
|
|
|
/** Builds the repository summaries' JSON array. */
|
|
|
public static JsonElement repo_list(Lot<RepoSummary> rows) throws Error {
|
|
|
var arr = new JsonArray();
|