mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat(mirror): enable gzip compression for repository mirror transfers (#250)
* feat(mirror): enable gzip compression for repository mirror transfers * fix(mirror): remove stale uncompressed progress, centralize gzip flag, dedupe test mocks * chore(mirror): drop dead progress update() method and unused phase field * chore(ocm-cli): bump version to 0.1.4
This commit is contained in:
1 parent
2b2cb6d23d
commit
500d4dfcc1
10 files changed
+124
-303
No files matched your search
@@ -90,12 +90,12 @@ export class ManagerApi {
|
||||
if (!res.ok) throw await formatErrorResponse(res, `mirror part ${index}`)
|
||||
}
|
||||
|
||||
async mirrorCommit(repoId: number, uploadId: string, totalParts: number): Promise<MirrorCommitResult> {
|
||||
async mirrorCommit(repoId: number, uploadId: string, totalParts: number, gzip: boolean): Promise<MirrorCommitResult> {
|
||||
const url = `${this.baseUrl}/api/internal/repos/${repoId}/mirror/commit`
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { ...this.headers(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ uploadId, totalParts }),
|
||||
body: JSON.stringify({ uploadId, totalParts, gzip }),
|
||||
})
|
||||
if (!res.ok) throw await formatErrorResponse(res, 'mirror commit')
|
||||
return (await res.json()) as MirrorCommitResult
|
||||
@@ -106,8 +106,9 @@ export class ManagerApi {
|
||||
await fetch(url, { method: 'DELETE', headers: this.headers() }).catch(() => { /* best-effort */ })
|
||||
}
|
||||
|
||||
async mirrorDown(repoId: number): Promise<ReadableStream<Uint8Array>> {
|
||||
const res = await fetch(`${this.baseUrl}/api/internal/repos/${repoId}/mirror`, {
|
||||
async mirrorDown(repoId: number, gzip: boolean): Promise<ReadableStream<Uint8Array>> {
|
||||
const query = gzip ? '?compress=gzip' : ''
|
||||
const res = await fetch(`${this.baseUrl}/api/internal/repos/${repoId}/mirror${query}`, {
|
||||
headers: this.headers(),
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user