MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / fetchZipMask

Function fetchZipMask

src/utils/zipImageFiles.ts:98–135  ·  view source on GitHub ↗
(imageName: string)

Source from the content-addressed store, hash-verified

96 * Extract a mask from ZIP.
97 */
98export async function fetchZipMask(imageName: string): Promise<File | null> {
99 const cached = zipMaskState.getCached(imageName);
100 if (cached) return cached;
101
102 if (!hasActiveZipArchive()) return null;
103
104 if (zipMaskState.isRequestPending(imageName)) {
105 return zipMaskState.waitForRequest(imageName);
106 }
107
108 const imageIndex = getActiveZipImageIndex();
109 if (!imageIndex) return null;
110
111 zipMaskState.startRequest(imageName);
112 let result: File | null = null;
113
114 try {
115 for (const maskPath of getMaskPathVariants(imageName)) {
116 const entry = findZipEntry(maskPath, imageIndex);
117 if (entry) {
118 try {
119 const file = await entry.extract();
120 zipMaskState.setCached(imageName, file);
121 result = file;
122 appLogger.info(`[ZIP Mask] Found mask for ${imageName}`);
123 return file;
124 } catch (err) {
125 appLogger.debug(`[ZIP Mask] Error extracting ${maskPath}:`, err);
126 }
127 }
128 }
129
130 appLogger.debug(`[ZIP Mask] No mask found for ${imageName}`);
131 return null;
132 } finally {
133 zipMaskState.completeRequest(imageName, result);
134 }
135}
136
137/**
138 * Remove specific entries from the ZIP mask cache.

Callers 3

getMaskFunction · 0.90

Calls 11

getMaskPathVariantsFunction · 0.90
hasActiveZipArchiveFunction · 0.85
getActiveZipImageIndexFunction · 0.85
findZipEntryFunction · 0.85
getCachedMethod · 0.80
isRequestPendingMethod · 0.80
waitForRequestMethod · 0.80
startRequestMethod · 0.80
extractMethod · 0.80
setCachedMethod · 0.80
completeRequestMethod · 0.80

Tested by

no test coverage detected