MCPcopy
hub / github.com/remotely-save/remotely-save / ensembleMixedEnties

Function ensembleMixedEnties

pro/src/sync.ts:359–534  ·  view source on GitHub ↗
(
  localEntityList: Entity[],
  prevSyncEntityList: Entity[],
  remoteEntityList: Entity[],

  syncConfigDir: boolean,
  syncBookmarks: boolean,
  configDir: string,
  syncUnderscoreItems: boolean,
  ignorePaths: string[],
  onlyAllowPaths: string[],
  fsEncrypt: FakeFsEncrypt,
  serviceType: SUPPORTED_SERVICES_TYPE,

  profiler: Profiler | undefined
)

Source from the content-addressed store, hash-verified

357export type SyncPlanType = Record<string, MixedEntity>;
358
359const ensembleMixedEnties = async (
360 localEntityList: Entity[],
361 prevSyncEntityList: Entity[],
362 remoteEntityList: Entity[],
363
364 syncConfigDir: boolean,
365 syncBookmarks: boolean,
366 configDir: string,
367 syncUnderscoreItems: boolean,
368 ignorePaths: string[],
369 onlyAllowPaths: string[],
370 fsEncrypt: FakeFsEncrypt,
371 serviceType: SUPPORTED_SERVICES_TYPE,
372
373 profiler: Profiler | undefined
374): Promise<SyncPlanType> => {
375 profiler?.addIndent();
376 profiler?.insert("ensembleMixedEnties: enter");
377 profiler?.insertSize("sizeof localEntityList", localEntityList);
378 profiler?.insertSize("sizeof prevSyncEntityList", prevSyncEntityList);
379 profiler?.insertSize("sizeof remoteEntityList", remoteEntityList);
380
381 const finalMappings: SyncPlanType = {};
382
383 const skipOrNotResults: Record<string, IsSkipResult> = {};
384
385 // remote has to be first
386 let remoteMaySkipCountAndNotConfig = 0;
387 for (const remote of remoteEntityList) {
388 const remoteCopied = ensureMTimeOfRemoteEntityValid(
389 copyEntityAndFixTimeFormat(remote, serviceType)
390 );
391
392 const key = remoteCopied.key!;
393
394 const skipOrNot = checkIsSkipItemOrNotByName(
395 key,
396 syncConfigDir,
397 syncBookmarks,
398 syncUnderscoreItems,
399 configDir,
400 ignorePaths,
401 onlyAllowPaths
402 );
403 skipOrNotResults[key] = skipOrNot;
404 if (skipOrNot.finalIsIgnored && !key.startsWith(configDir)) {
405 remoteMaySkipCountAndNotConfig += 1;
406 }
407
408 // 20240907: users (not on windows) doesn't like it. revert back now.
409 // TODO: platform specific but not introducing obsidian dependency into sync.ts
410 // const checkValidNameResult = checkValidName(key);
411 // if (!checkValidNameResult.result) {
412 // throw Error(
413 // `your remote folder/file name is invalid: ${checkValidNameResult.reason}`
414 // );
415 // }
416

Callers 1

syncerFunction · 0.85

Calls 9

getSkipItemsByListFunction · 0.85
addIndentMethod · 0.80
insertMethod · 0.80
insertSizeMethod · 0.80
encryptEntityMethod · 0.80
removeIndentMethod · 0.80

Tested by

no test coverage detected