In my opinion there should be an additional condition that checks if there's exactly one temporary but already finished item. That is, there could be many temporary items, but there's only one that has "isUpdating" false. In this case this would be the item to replace. According to my observations this is exactly what happens when installing store apps: "installFinished" gets called for the temporary item before the permanent item appears.