MCPcopy
hub / github.com/immich-app/immich / syncAlbumAssetExifsV1

Method syncAlbumAssetExifsV1

server/src/services/sync.service.ts:591–660  ·  view source on GitHub ↗
(
    options: SyncQueryOptions,
    response: Writable,
    checkpointMap: CheckpointMap,
    sessionId: string,
  )

Source from the content-addressed store, hash-verified

589 }
590
591 private async syncAlbumAssetExifsV1(
592 options: SyncQueryOptions,
593 response: Writable,
594 checkpointMap: CheckpointMap,
595 sessionId: string,
596 ) {
597 const backfillType = SyncEntityType.AlbumAssetExifBackfillV1;
598 const backfillCheckpoint = checkpointMap[backfillType];
599 const albums = await this.syncRepository.album.getCreatedAfter({
600 ...options,
601 afterCreateId: backfillCheckpoint?.updateId,
602 });
603 const updateType = SyncEntityType.AlbumAssetExifUpdateV1;
604 const createType = SyncEntityType.AlbumAssetExifCreateV1;
605 const upsertCheckpoint = checkpointMap[updateType];
606 const createCheckpoint = checkpointMap[createType];
607 if (createCheckpoint) {
608 const endId = createCheckpoint.updateId;
609
610 for (const album of albums) {
611 const createId = album.createId;
612 if (isEntityBackfillComplete(createId, backfillCheckpoint)) {
613 continue;
614 }
615
616 const startId = getStartId(createId, backfillCheckpoint);
617 const backfill = this.syncRepository.albumAssetExif.getBackfill(
618 { ...options, afterUpdateId: startId, beforeUpdateId: endId },
619 album.id,
620 );
621
622 for await (const { updateId, ...data } of backfill) {
623 send(response, { type: backfillType, ids: [createId, updateId], data });
624 }
625
626 sendEntityBackfillCompleteAck(response, backfillType, createId);
627 }
628 } else if (albums.length > 0) {
629 await this.upsertBackfillCheckpoint({
630 type: backfillType,
631 sessionId,
632 createId: albums.at(-1)!.createId,
633 });
634 }
635
636 if (createCheckpoint) {
637 const updates = this.syncRepository.albumAssetExif.getUpdates(
638 { ...options, ack: upsertCheckpoint },
639 createCheckpoint,
640 );
641 for await (const { updateId, ...data } of updates) {
642 send(response, { type: updateType, ids: [updateId], data });
643 }
644 }
645
646 const creates = this.syncRepository.albumAssetExif.getCreates({ ...options, ack: createCheckpoint });
647 let first = true;
648 for await (const { updateId, ...data } of creates) {

Callers 1

streamMethod · 0.95

Calls 9

isEntityBackfillCompleteFunction · 0.85
getStartIdFunction · 0.85
sendFunction · 0.85
getCreatedAfterMethod · 0.45
getBackfillMethod · 0.45
getUpdatesMethod · 0.45
getCreatesMethod · 0.45

Tested by

no test coverage detected