MCPcopy Create free account
hub / github.com/decaporg/decap-cms / readFileMetadata

Function readFileMetadata

packages/decap-cms-lib-util/src/API.ts:286–302  ·  view source on GitHub ↗
(
  id: string | null | undefined,
  fetchMetadata: () => Promise<FileMetadata>,
  localForage: LocalForage,
)

Source from the content-addressed store, hash-verified

284}
285
286export async function readFileMetadata(
287 id: string | null | undefined,
288 fetchMetadata: () => Promise<FileMetadata>,
289 localForage: LocalForage,
290) {
291 const key = id ? getFileMetadataKey(id) : null;
292 const cached = key && (await localForage.getItem<FileMetadata>(key));
293 if (cached) {
294 return cached;
295 }
296
297 const metadata = await fetchMetadata();
298 if (key) {
299 await localForage.setItem<FileMetadata>(key, metadata);
300 }
301 return metadata;
302}
303
304/**
305 * Keywords for inferring a status that will provide a deploy preview URL.

Callers 7

readFileMetadataMethod · 0.90
readFileMetadataMethod · 0.90
readFileMetadataMethod · 0.90
readFileMetadataMethod · 0.90
readFileMetadataMethod · 0.90
readFileMetadataMethod · 0.90
fetchFilesFunction · 0.85

Calls 1

getFileMetadataKeyFunction · 0.85

Tested by

no test coverage detected