archives: use separate table

Cleaner to separate things from the backups table.

* icon, appConfig, appStoreIcon etc are only valid for archives
* older version cloudron does not have appConfig in backups table (so it
  cannot be an archive entry)
This commit is contained in:
Girish Ramakrishnan
2024-12-10 10:06:52 +01:00
parent 2ad93c114e
commit 490840b71d
12 changed files with 261 additions and 122 deletions

View File

@@ -146,6 +146,7 @@ exports = module.exports = {
const appstore = require('./appstore.js'),
appTaskManager = require('./apptaskmanager.js'),
archives = require('./archives.js'),
assert = require('assert'),
backups = require('./backups.js'),
BoxError = require('./boxerror.js'),
@@ -2496,8 +2497,7 @@ async function archive(app, backupId, auditSource) {
const icons = await getIcons(app.id);
const { taskId } = await uninstall(app, auditSource);
await backups.update(result[0].id, { archive: true, icon: icons.icon, appStoreIcon: icons.appStoreIcon });
if (!result[0].appConfig) await backups.update(result[0].id, { appConfig: app }); // workaround for previous versions not setting appConfig
await archives.add(backupId, { icon: icons.icon, appStoreIcon: icons.appStoreIcon, appConfig: app });
return { taskId };
}