app backup filename now has fqdn

Part of cloudron/box#782
This commit is contained in:
Girish Ramakrishnan
2021-05-08 17:18:26 -07:00
parent 445325453b
commit c56c43c464

View File

@@ -659,15 +659,22 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
$scope.backups = $scope.backups.slice(0, 20); // only show 20 since we don't have pagination
// add contents property
var appsById = {};
Client.getInstalledApps().forEach(function (app) { appsById[app.id] = app; });
var appsById = {}, appsByFqdn = {};
Client.getInstalledApps().forEach(function (app) {
appsById[app.id] = app;
appsByFqdn[app.fqdn] = app;
});
$scope.backups.forEach(function (backup) {
backup.contents = [];
backup.dependsOn.forEach(function (appBackupId) {
let match = appBackupId.match(/app_(.*?)_.*/); // *? means non-greedy
if (!match || !appsById[match[1]]) return;
backup.contents.push(appsById[match[1]]);
if (!match) return;
if (match[1].indexOf('.') !== -1) { // newer backups have fqdn in them
if (appsByFqdn[match[1]]) backup.contents.push(appsByFqdn[match[1]]);
} else {
if (appsById[match[1]]) backup.contents.push(appsById[match[1]]);
}
});
});
});