app archive: fix download config

This commit is contained in:
Girish Ramakrishnan
2025-10-06 22:31:17 +02:00
parent b3eb6ccde3
commit 28c0d63f89
5 changed files with 27 additions and 36 deletions
+5 -11
View File
@@ -12,8 +12,10 @@ import AppRestoreDialog from '../components/AppRestoreDialog.vue';
import Section from '../components/Section.vue';
import ArchivesModel from '../models/ArchivesModel.js';
import { download } from '../utils.js';
import BackupSitesModel from '../models/BackupSitesModel.js';
const archivesModel = ArchivesModel.create();
const backupSitesModel = BackupSitesModel.create();
const columns = {
icon: {}, // archived
@@ -98,19 +100,11 @@ async function onRestore(archive) {
}
async function onDownloadConfig(archive) {
// secrets and tokens already come with placeholder characters we remove them
// TODO fill tmp from target config
const tmp = {
remotePath: archive.remotePath,
// encrypted: !!props.config.password // we add this just to help the import UI
};
// Object.keys(props.config).forEach((k) => {
// if (props.config[k] !== SECRET_PLACEHOLDER) tmp[k] = props.config[k];
// });
const [backupConfigError, backupConfig] = await backupSitesModel.generateBackupConfig(archive);
if (backupConfigError) return console.error(backupConfigError);
const filename = `${archive.appConfig.fqdn}-archive-config-${(new Date(archive.creationTime)).toISOString().split('T')[0]}.json`;
download(filename, JSON.stringify(tmp, null, 4));
download(filename, JSON.stringify(backupConfig, null, 4));
}
onMounted(async () => {
+3 -12
View File
@@ -197,20 +197,11 @@ async function onDownloadConfig(backup) {
const [error, dashboardConfig] = await dashboardModel.config();
if (error) return console.error(error);
const [backupSiteError, backupSite] = await backupSitesModel.get(backup.siteId);
if (backupSiteError) return console.error(backupSiteError);
const tmp = {
remotePath: backup.remotePath
};
for (const k of ['provider', 'config', 'limits', 'format', 'encrypted', 'encryptedFilenames', 'encryptionPasswordHint']) {
tmp[k] = backupSite[k];
}
tmp.siteId = backupSite.id;
const [backupConfigError, backupConfig] = await backupSitesModel.generateBackupConfig(backup);
if (backupConfigError) return console.error(backupConfigError);
const filename = `${dashboardConfig.adminFqdn}-backup-config-${(new Date(backup.creationTime)).toISOString().split('T')[0]}.json`;
download(filename, JSON.stringify(tmp, null, 4));
download(filename, JSON.stringify(backupConfig, null, 4));
}
// backups info dialog