MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / downloadZip

Function downloadZip

src/utils/zipDownload.ts:30–56  ·  view source on GitHub ↗
(
  url: string,
  onProgress: ZipProgressCallback,
  options: ZipDownloadOptions = {}
)

Source from the content-addressed store, hash-verified

28 * Download an archive file from URL with progress tracking.
29 */
30export async function downloadZip(
31 url: string,
32 onProgress: ZipProgressCallback,
33 options: ZipDownloadOptions = {}
34): Promise<Blob> {
35 const fetchImpl = options.fetchImpl ?? fetchWithTimeout;
36 const timeoutMs = options.timeoutMs ?? DOWNLOAD_TIMEOUT;
37
38 onProgress({ percent: 2, message: 'Starting download...' });
39
40 const response = await fetchImpl(url, timeoutMs);
41
42 if (!response.ok) {
43 throw new Error(`Failed to download archive (${response.status})`);
44 }
45
46 const contentLength = response.headers.get('content-length');
47 const total = contentLength ? parseSafeIntegerString(contentLength) ?? 0 : 0;
48
49 if (!response.body) {
50 return response.blob();
51 }
52
53 const blob = await readStreamingResponseBlob(response.body, total, onProgress);
54 validateDownloadedArchiveSize(blob, options.sizeLimit);
55 return blob;
56}
57
58/**
59 * Validate downloaded archive size after streaming or fallback blob creation.

Callers 2

loadZipFromUrlFunction · 0.90

Calls 5

parseSafeIntegerStringFunction · 0.90
getMethod · 0.80
blobMethod · 0.80

Tested by

no test coverage detected