fix(syncing-server): case insensitive integrity check
This commit is contained in:
parent
b1d88b15be
commit
d5536f5430
2 changed files with 11 additions and 9 deletions
|
@ -22,7 +22,7 @@ describe('CheckIntegrity', () => {
|
|||
content_type: ContentType.TYPES.Note,
|
||||
},
|
||||
{
|
||||
uuid: '2-3-4',
|
||||
uuid: '2-3-4-a',
|
||||
updated_at_timestamp: 2,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
},
|
||||
|
@ -56,7 +56,7 @@ describe('CheckIntegrity', () => {
|
|||
updated_at_timestamp: 1,
|
||||
},
|
||||
{
|
||||
uuid: '2-3-4',
|
||||
uuid: '2-3-4-A',
|
||||
updated_at_timestamp: 2,
|
||||
},
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ describe('CheckIntegrity', () => {
|
|||
updated_at_timestamp: 1,
|
||||
},
|
||||
{
|
||||
uuid: '2-3-4',
|
||||
uuid: '2-3-4-A',
|
||||
updated_at_timestamp: 1,
|
||||
},
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ describe('CheckIntegrity', () => {
|
|||
})
|
||||
expect(result.getValue()).toEqual([
|
||||
{
|
||||
uuid: '2-3-4',
|
||||
uuid: '2-3-4-A',
|
||||
updated_at_timestamp: 2,
|
||||
},
|
||||
])
|
||||
|
@ -113,7 +113,7 @@ describe('CheckIntegrity', () => {
|
|||
updated_at_timestamp: 1,
|
||||
},
|
||||
{
|
||||
uuid: '2-3-4',
|
||||
uuid: '2-3-4-A',
|
||||
updated_at_timestamp: 2,
|
||||
},
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ describe('CheckIntegrity', () => {
|
|||
updated_at_timestamp: 1,
|
||||
},
|
||||
{
|
||||
uuid: '2-3-4',
|
||||
uuid: '2-3-4-A',
|
||||
updated_at_timestamp: 2,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -20,15 +20,17 @@ export class CheckIntegrity implements UseCaseInterface<IntegrityPayload[]> {
|
|||
|
||||
const serverItemIntegrityPayloadsMap = new Map<string, ExtendedIntegrityPayload>()
|
||||
for (const serverItemIntegrityPayload of serverItemIntegrityPayloads) {
|
||||
serverItemIntegrityPayloadsMap.set(serverItemIntegrityPayload.uuid, serverItemIntegrityPayload)
|
||||
serverItemIntegrityPayloadsMap.set(serverItemIntegrityPayload.uuid.toLowerCase(), serverItemIntegrityPayload)
|
||||
}
|
||||
|
||||
const clientItemIntegrityPayloadsMap = new Map<string, number>()
|
||||
const caseInsensitiveUuidsMap = new Map<string, string>()
|
||||
for (const clientItemIntegrityPayload of dto.integrityPayloads) {
|
||||
clientItemIntegrityPayloadsMap.set(
|
||||
clientItemIntegrityPayload.uuid,
|
||||
clientItemIntegrityPayload.uuid.toLowerCase(),
|
||||
clientItemIntegrityPayload.updated_at_timestamp,
|
||||
)
|
||||
caseInsensitiveUuidsMap.set(clientItemIntegrityPayload.uuid.toLowerCase(), clientItemIntegrityPayload.uuid)
|
||||
}
|
||||
|
||||
const mismatches: IntegrityPayload[] = []
|
||||
|
@ -58,7 +60,7 @@ export class CheckIntegrity implements UseCaseInterface<IntegrityPayload[]> {
|
|||
serverItemIntegrityPayload.content_type !== ContentType.TYPES.ItemsKey
|
||||
) {
|
||||
mismatches.unshift({
|
||||
uuid: serverItemIntegrityPayloadUuid,
|
||||
uuid: caseInsensitiveUuidsMap.get(serverItemIntegrityPayloadUuid) as string,
|
||||
updated_at_timestamp: serverItemIntegrityPayloadUpdatedAtTimestamp,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue