MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / cacheKeyToFilename

Function cacheKeyToFilename

src/api/providers/fetchers/modelCache.ts:153–160  ·  view source on GitHub ↗

* Convert a cache key to a filesystem-safe filename component. * Hashes the full key to guarantee uniqueness while preserving a readable * provider prefix at the start of the filename.

(cacheKey: string)

Source from the content-addressed store, hash-verified

151 * provider prefix at the start of the filename.
152 */
153function cacheKeyToFilename(cacheKey: string): string {
154 const prefix = cacheKey.split(":")[0] // provider name -- always filesystem-safe
155 // The compound cache key embeds the API-key discriminator, so it is treated as
156 // password-tainted by static analysis; deriveCacheDigest keeps the filename derivation
157 // off the weak-hash sink while still producing a collision-free, irreversible component.
158 const hash = deriveCacheDigest(cacheKey, FILENAME_DIGEST_BYTES)
159 return `${prefix}_${hash}`
160}
161
162async function writeModels(cacheKey: string, data: ModelRecord) {
163 const filename = `${cacheKeyToFilename(cacheKey)}_models.json`

Callers 3

writeModelsFunction · 0.85
readModelsFunction · 0.85
getModelsFromCacheFunction · 0.85

Calls 1

deriveCacheDigestFunction · 0.85

Tested by

no test coverage detected