merge appdb.js into apps.js

This commit is contained in:
Girish Ramakrishnan
2021-08-20 09:19:44 -07:00
parent b6f2d6d620
commit 77f5cb183b
39 changed files with 1599 additions and 2495 deletions
+7 -8
View File
@@ -12,8 +12,7 @@ exports = module.exports = {
_waitForDnsPropagation: waitForDnsPropagation
};
const appdb = require('./appdb.js'),
apps = require('./apps.js'),
const apps = require('./apps.js'),
assert = require('assert'),
async = require('async'),
auditSource = require('./auditsource.js'),
@@ -70,7 +69,7 @@ function updateApp(app, values, callback) {
assert.strictEqual(typeof values, 'object');
assert.strictEqual(typeof callback, 'function');
appdb.update(app.id, values, function (error) {
util.callbackify(apps.update)(app.id, values, function (error) {
if (error) return callback(error);
for (var value in values) {
@@ -403,7 +402,7 @@ function install(app, args, progressCallback, callback) {
docker.deleteImage(oldManifest, done);
},
// allocating container ip here, lets the users "repair" an app if allocation fails at appdb.add time
// allocating container ip here, lets the users "repair" an app if allocation fails at apps.add time
allocateContainerIp.bind(null, app),
progressCallback.bind(null, { percent: 20, message: 'Downloading icon' }),
@@ -447,7 +446,7 @@ function install(app, args, progressCallback, callback) {
backuptask.downloadApp.bind(null, app, restoreConfig, (progress) => {
progressCallback({ percent: 65, message: progress.message });
}),
(done) => { if (app.installationState === apps.ISTATE_PENDING_IMPORT) apps.restoreConfig(app, done); else done(); },
async () => { if (app.installationState === apps.ISTATE_PENDING_IMPORT) await apps.restoreConfig(app); },
progressCallback.bind(null, { percent: 70, message: 'Restoring addons' }),
services.restoreAddons.bind(null, app, app.manifest.addons)
], next);
@@ -759,7 +758,7 @@ function update(app, args, progressCallback, callback) {
async.each(Object.keys(currentPorts), function (portName, callback) {
if (newTcpPorts[portName] || newUdpPorts[portName]) return callback(null); // port still in use
appdb.delPortBinding(currentPorts[portName], apps.PORT_TYPE_TCP, function (error) {
apps.delPortBinding(currentPorts[portName], apps.PORT_TYPE_TCP, function (error) {
if (error && error.reason === BoxError.NOT_FOUND) debugApp(app, 'update: portbinding does not exist in database', error);
else if (error) return next(error);
@@ -914,7 +913,7 @@ function uninstall(app, args, progressCallback, callback) {
cleanupLogs.bind(null, app),
progressCallback.bind(null, { percent: 95, message: 'Remove app from database' }),
appdb.del.bind(null, app.id)
apps.del.bind(null, app.id)
], function seriesDone(error) {
if (error) {
debugApp(app, 'error uninstalling app:', error);
@@ -931,7 +930,7 @@ function run(appId, args, progressCallback, callback) {
assert.strictEqual(typeof callback, 'function');
// determine what to do
apps.get(appId, function (error, app) {
util.callbackify(apps.get)(appId, function (error, app) {
if (error) return callback(error);
debugApp(app, `startTask installationState: ${app.installationState} runState: ${app.runState}`);