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

Function readFileMetadata

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

Source from the content-addressed store, hash-verified

281}
282
283export async function readFileMetadata(
284 id: string | null | undefined,
285 fetchMetadata: () => Promise<FileMetadata>,
286 localForage: LocalForage,
287) {
288 const key = id ? getFileMetadataKey(id) : null;
289 const cached = key && (await localForage.getItem<FileMetadata>(key));
290 if (cached) {
291 return cached;
292 }
293
294 const metadata = await fetchMetadata();
295 if (key) {
296 await localForage.setItem<FileMetadata>(key, metadata);
297 }
298 return metadata;
299}
300
301/**
302 * 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