MCPcopy Create free account
hub / github.com/craftreactnative/ui / isCacheStale

Function isCacheStale

cli/src/utils/github-downloader.ts:51–70  ·  view source on GitHub ↗

* Checks if cache is stale based on timestamp (1 day)

(
  branch: string,
  forceLatest: boolean
)

Source from the content-addressed store, hash-verified

49 * Checks if cache is stale based on timestamp (1 day)
50 */
51async function isCacheStale(
52 branch: string,
53 forceLatest: boolean
54): Promise<boolean> {
55 if (forceLatest) return true;
56
57 const metadataPath = getCacheMetadataPath(branch);
58 if (!(await fs.pathExists(metadataPath))) {
59 return true; // No cache metadata, consider stale
60 }
61
62 try {
63 const metadata: CacheMetadata = await fs.readJson(metadataPath);
64 const age = Date.now() - metadata.timestamp;
65 return age > CACHE_STALENESS_MS;
66 } catch (error) {
67 // If we can't read metadata, consider stale
68 return true;
69 }
70}
71
72/**
73 * Saves cache metadata with timestamp

Callers 1

downloadFromGitHubFunction · 0.85

Calls 1

getCacheMetadataPathFunction · 0.85

Tested by

no test coverage detected