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

Method deleteMetadata

packages/decap-cms-backend-github/src/API.ts:487–508  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

485 }
486
487 deleteMetadata(key: string) {
488 if (!this._metadataSemaphore) {
489 this._metadataSemaphore = semaphore(1);
490 }
491 return new Promise<void>(resolve =>
492 this._metadataSemaphore?.take(async () => {
493 try {
494 const branchData = await this.checkMetadataRef();
495 const file = { path: `${key}.json`, sha: null };
496
497 const changeTree = await this.updateTree(branchData.sha, [file]);
498 const { sha } = await this.commit(`Deleting “${key}” metadata`, changeTree);
499 await this.patchRef('meta', '_decap_cms', sha);
500 this._metadataSemaphore?.leave();
501 resolve();
502 } catch (err) {
503 this._metadataSemaphore?.leave();
504 resolve();
505 }
506 }),
507 );
508 }
509
510 async retrieveMetadataOld(key: string): Promise<Metadata> {
511 console.log(

Callers 2

migrateToVersion1Method · 0.95

Calls 4

checkMetadataRefMethod · 0.95
updateTreeMethod · 0.95
commitMethod · 0.95
patchRefMethod · 0.95

Tested by

no test coverage detected