mirror of
https://github.com/getnora-io/nora.git
synced 2026-04-12 17:20:33 +00:00
feat: add Docker image metadata support
- Store metadata (.meta.json) alongside manifests with: - push_timestamp, last_pulled, downloads counter - size_bytes, os, arch, variant - layers list with digest and size - Update metadata on manifest pull (increment downloads, update last_pulled) - Extract OS/arch from config blob on push - Extend UI API TagInfo with metadata fields - Add public_url config option for pull commands - Add Docker upstream proxy with auth support - Add raw repository support - Bump version to 0.2.12
This commit is contained in:
@@ -80,7 +80,7 @@ async fn package_versions(
|
||||
|
||||
// Try proxy if configured
|
||||
if let Some(proxy_url) = &state.config.pypi.proxy {
|
||||
let url = format!("{}{}/", proxy_url.trim_end_matches('/'), normalized);
|
||||
let url = format!("{}/{}/", proxy_url.trim_end_matches('/'), normalized);
|
||||
|
||||
if let Ok(html) = fetch_package_page(&url, state.config.pypi.proxy_timeout).await {
|
||||
// Rewrite URLs in the HTML to point to our registry
|
||||
@@ -125,7 +125,7 @@ async fn download_file(
|
||||
// Try proxy if configured
|
||||
if let Some(proxy_url) = &state.config.pypi.proxy {
|
||||
// First, fetch the package page to find the actual download URL
|
||||
let page_url = format!("{}{}/", proxy_url.trim_end_matches('/'), normalized);
|
||||
let page_url = format!("{}/{}/", proxy_url.trim_end_matches('/'), normalized);
|
||||
|
||||
if let Ok(html) = fetch_package_page(&page_url, state.config.pypi.proxy_timeout).await {
|
||||
// Find the URL for this specific file
|
||||
@@ -233,6 +233,30 @@ fn rewrite_pypi_links(html: &str, package_name: &str) -> String {
|
||||
}
|
||||
}
|
||||
result.push_str(remaining);
|
||||
|
||||
// Remove data-core-metadata and data-dist-info-metadata attributes
|
||||
// as we don't serve .metadata files (PEP 658)
|
||||
let result = remove_attribute(&result, "data-core-metadata");
|
||||
let result = remove_attribute(&result, "data-dist-info-metadata");
|
||||
result
|
||||
}
|
||||
|
||||
/// Remove an HTML attribute from all tags
|
||||
fn remove_attribute(html: &str, attr_name: &str) -> String {
|
||||
let mut result = String::with_capacity(html.len());
|
||||
let mut remaining = html;
|
||||
let pattern = format!(" {}=\"", attr_name);
|
||||
|
||||
while let Some(attr_start) = remaining.find(&pattern) {
|
||||
result.push_str(&remaining[..attr_start]);
|
||||
remaining = &remaining[attr_start + pattern.len()..];
|
||||
|
||||
// Skip the attribute value
|
||||
if let Some(attr_end) = remaining.find('"') {
|
||||
remaining = &remaining[attr_end + 1..];
|
||||
}
|
||||
}
|
||||
result.push_str(remaining);
|
||||
result
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user