MCPcopy Create free account
hub / github.com/appium/appium / ensureFileStructure

Function ensureFileStructure

scripts/crowdin-update-docs-resources.mjs:200–227  ·  view source on GitHub ↗

* @param {Record } storageMapping * @param {Record } directoriesMapping * @param {Record []} existingFilesData * @returns {Promise >}

(storageMapping, directoriesMapping, existingFilesData)

Source from the content-addressed store, hash-verified

198 * @returns {Promise<Record<string, number>>}
199 */
200async function ensureFileStructure(storageMapping, directoriesMapping, existingFilesData) {
201 const result = {};
202 let count = 0;
203 for (const [fullPath, storageId] of Object.entries(storageMapping)) {
204 const pathInCrowdin = toCrowdinPath(fullPath);
205 log.info(`Synchronizing '${pathInCrowdin}' (${++count} of ${Object.keys(storageMapping).length})`);
206 const fileData = existingFilesData.find((data) => data.path === pathInCrowdin);
207 if (fileData) {
208 result[fullPath] = fileData.id;
209 } else {
210 const parentFolderId = directoriesMapping[path.dirname(pathInCrowdin)];
211 try {
212 const fileId = await addFile(encodeURIComponent(path.basename(pathInCrowdin)), storageId, parentFolderId);
213 result[fullPath] = fileId;
214 } catch (e) {
215 log.warn(`Cannot add '${pathInCrowdin}'. Skipping it`);
216 if (e.response) {
217 log.info(`Crowdin API status: ${e.response.status}`);
218 log.info(`Crowdin API error: ${JSON.stringify(e.response.data, null, 2)}`);
219 } else {
220 log.info(e);
221 }
222 continue;
223 }
224 }
225 }
226 return result;
227}
228
229/**
230 * @returns {Promise<void>}

Callers 2

updateDocumentsFunction · 0.85
updateMkDocsConfigFunction · 0.85

Calls 5

toCrowdinPathFunction · 0.85
addFileFunction · 0.85
findMethod · 0.80
infoMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected