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

Method persistFiles

packages/decap-cms-backend-github/src/API.ts:947–969  ·  view source on GitHub ↗
(dataFiles: DataFile[], mediaFiles: AssetProxy[], options: PersistOptions)

Source from the content-addressed store, hash-verified

945 }
946
947 async persistFiles(dataFiles: DataFile[], mediaFiles: AssetProxy[], options: PersistOptions) {
948 const files = mediaFiles.concat(dataFiles);
949 const uploadPromises = files.map(file => this.uploadBlob(file));
950 await Promise.all(uploadPromises);
951
952 if (!options.useWorkflow) {
953 return this.getDefaultBranch()
954 .then(branchData =>
955 this.updateTree(branchData.commit.sha, files as { sha: string; path: string }[]),
956 )
957 .then(changeTree => this.commit(options.commitMessage, changeTree))
958 .then(response => this.patchBranch(this.branch, response.sha));
959 } else {
960 const mediaFilesList = (mediaFiles as { sha: string; path: string }[]).map(
961 ({ sha, path }) => ({
962 path: trimStart(path, '/'),
963 sha,
964 }),
965 );
966 const slug = dataFiles[0].slug;
967 return this.editorialWorkflowGit(files as TreeFile[], slug, mediaFilesList, options);
968 }
969 }
970
971 async getFileSha(path: string, { repoURL = this.repoURL, branch = this.branch } = {}) {
972 /**

Callers 3

persistEntryMethod · 0.45
persistMediaMethod · 0.45
API.spec.jsFile · 0.45

Calls 7

uploadBlobMethod · 0.95
getDefaultBranchMethod · 0.95
updateTreeMethod · 0.95
commitMethod · 0.95
patchBranchMethod · 0.95
editorialWorkflowGitMethod · 0.95
mapMethod · 0.80

Tested by

no test coverage detected