Remove saving Apps in the legacy format

This commit is contained in:
Jonas Lochmann 2022-11-14 01:00:00 +01:00
parent f5198c7c0b
commit 89e9b85bda
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
8 changed files with 40 additions and 205 deletions

View file

@ -16,44 +16,12 @@
*/
import { UpdateInstalledAppsAction } from '../../../../action'
import { types } from '../../../../database/encryptedapplist'
import { generateVersionId } from '../../../../util/token'
import { Cache } from '../cache'
export async function dispatchUpdateInstalledApps ({ deviceId, action, cache }: {
export async function dispatchUpdateInstalledApps (_: {
deviceId: string
action: UpdateInstalledAppsAction
cache: Cache
}) {
async function upsert({ type, data }: { type: number, data: Buffer }) {
await cache.database.encryptedAppList.upsert({
familyId: cache.familyId,
deviceId,
type,
version: generateVersionId(),
data
}, { transaction: cache.transaction })
}
if (action.base) {
await upsert({ type: types.base, data: action.base })
}
if (action.diff) {
await upsert({ type: types.diff, data: action.diff })
}
if (action.wipe) {
await cache.database.app.destroy({
where: {
familyId: cache.familyId,
deviceId
},
transaction: cache.transaction
})
cache.devicesWithModifiedInstalledApps.add(deviceId)
}
cache.incrementTriggeredSyncLevel(1)
// do nothing
}