feat(core,storage,oci,registry-config): add streaming response support and configurable registry URLs across protocols
This commit is contained in:
@@ -303,21 +303,33 @@ export class RubyGemsRegistry extends BaseRegistry {
|
||||
return this.errorResponse(400, 'Invalid gem filename');
|
||||
}
|
||||
|
||||
let gemData = await this.storage.getRubyGemsGem(
|
||||
// Try streaming from local storage first
|
||||
const streamResult = await this.storage.getRubyGemsGemStream(
|
||||
parsed.name,
|
||||
parsed.version,
|
||||
parsed.platform
|
||||
);
|
||||
|
||||
if (streamResult) {
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
'Content-Length': streamResult.size.toString()
|
||||
},
|
||||
body: streamResult.stream,
|
||||
};
|
||||
}
|
||||
|
||||
// Try upstream if not found locally
|
||||
if (!gemData) {
|
||||
const upstream = await this.getUpstreamForRequest(parsed.name, 'gem', 'GET', actor);
|
||||
if (upstream) {
|
||||
gemData = await upstream.fetchGem(parsed.name, parsed.version);
|
||||
if (gemData) {
|
||||
// Cache locally
|
||||
await this.storage.putRubyGemsGem(parsed.name, parsed.version, gemData, parsed.platform);
|
||||
}
|
||||
let gemData: Buffer | null = null;
|
||||
const upstream = await this.getUpstreamForRequest(parsed.name, 'gem', 'GET', actor);
|
||||
if (upstream) {
|
||||
gemData = await upstream.fetchGem(parsed.name, parsed.version);
|
||||
if (gemData) {
|
||||
// Cache locally
|
||||
await this.storage.putRubyGemsGem(parsed.name, parsed.version, gemData, parsed.platform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ export async function extractGemMetadata(gemData: Buffer): Promise<{
|
||||
// Step 2: Decompress the gzipped metadata
|
||||
const gzipTools = new plugins.smartarchive.GzipTools();
|
||||
const metadataYaml = await gzipTools.decompress(metadataFile.contentBuffer);
|
||||
const yamlContent = metadataYaml.toString('utf-8');
|
||||
const yamlContent = Buffer.from(metadataYaml).toString('utf-8');
|
||||
|
||||
// Step 3: Parse the YAML to extract name, version, platform
|
||||
// Look for name: field in YAML
|
||||
@@ -503,7 +503,7 @@ export async function generateSpecsGz(specs: Array<[string, string, string]>): P
|
||||
}
|
||||
|
||||
const uncompressed = Buffer.concat(parts);
|
||||
return gzipTools.compress(uncompressed);
|
||||
return Buffer.from(await gzipTools.compress(uncompressed));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user