Skip to content

Commit 817be1c

Browse files
committed
fix: Throw MappingFailureError on failed id mapping
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent f5fffd3 commit 817be1c

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/lib/Diff.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ export default class Diff<
335335
action.payload,
336336
targetLocation
337337
)
338+
if (action.type !== ActionType.CREATE && typeof action.payload.id !== 'undefined' && typeof newAction.payload.id === 'undefined') {
339+
Logger.log(
340+
'payload.location = ' +
341+
action.payload.location +
342+
' | targetLocation = ' +
343+
targetLocation
344+
)
345+
const diff = new Diff()
346+
diff.commit(action)
347+
Logger.log('Failed to map id of action ' + diff.inspect())
348+
Logger.log(JSON.stringify(mappingsSnapshot, null, '\t'))
349+
throw new MappingFailureError(String(action.payload.id))
350+
}
338351
}
339352

340353
if (
@@ -397,6 +410,10 @@ export default class Diff<
397410
})
398411
}
399412

413+
if (action.type !== ActionType.REORDER) {
414+
Logger.log('Mapped action', action, newAction)
415+
}
416+
400417
newDiff.commit(newAction)
401418
})
402419
return newDiff

src/lib/strategies/Merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Folder, ItemLocation, ItemType, TItem, TItemLocation, TOppositeLocation } from '../Tree'
1+
import { Folder, ItemLocation, TItemLocation, TOppositeLocation } from '../Tree'
22
import Diff, { CreateAction, MoveAction, PlanStage1 } from '../Diff'
33
import Scanner, { ScanResult } from '../Scanner'
44
import * as Parallel from 'async-parallel'

0 commit comments

Comments
 (0)