MCPcopy Create free account
hub / github.com/subquery/subql / fetchAndSaveFile

Function fetchAndSaveFile

packages/node-core/src/utils/project.ts:182–191  ·  view source on GitHub ↗
(reader: Reader, root: string, file: string, ext = 'js')

Source from the content-addressed store, hash-verified

180}
181
182export async function fetchAndSaveFile(reader: Reader, root: string, file: string, ext = 'js'): Promise<string> {
183 if (!(reader instanceof IPFSReader || reader instanceof GithubReader)) {
184 throw new Error('Only IPFS and Github readers can save remote files');
185 }
186 const res = await reader.getFile(file);
187 if (!res) {
188 throw new Error(`Unable to read file ${file}`);
189 }
190 return saveFile(reader, root, file, res, ext);
191}
192
193export async function saveFile(reader: Reader, root: string, file: string, data: string, ext = 'js'): Promise<string> {
194 if (!(reader instanceof IPFSReader || reader instanceof GithubReader)) {

Callers 2

updateDataSourcesV1_0_0Function · 0.85
updateProcessorFunction · 0.85

Calls 2

saveFileFunction · 0.85
getFileMethod · 0.65

Tested by

no test coverage detected