Fix signature of checkForPortBindingsConflict
This commit is contained in:
14
src/apps.js
14
src/apps.js
@@ -794,13 +794,13 @@ function accessLevel(app, user) {
|
||||
return canAccess(app, user) ? 'user' : null;
|
||||
}
|
||||
|
||||
async function checkForPortBindingConflict(portBindings, id = '') {
|
||||
async function checkForPortBindingConflict(portBindings, options) {
|
||||
assert.strictEqual(typeof portBindings, 'object');
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
|
||||
let existingPortBindings;
|
||||
if (id) existingPortBindings = await database.query('SELECT * FROM appPortBindings WHERE appId != ?', [ id ]);
|
||||
else existingPortBindings = await database.query('SELECT * FROM appPortBindings', []);
|
||||
const existingPortBindings = options.appId
|
||||
? await database.query('SELECT * FROM appPortBindings WHERE appId != ?', [ options.appId ])
|
||||
: await database.query('SELECT * FROM appPortBindings', []);
|
||||
|
||||
if (existingPortBindings.length === 0) return;
|
||||
|
||||
@@ -863,7 +863,7 @@ async function add(id, appStoreId, manifest, subdomain, domain, portBindings, da
|
||||
enableRedis = 'enableRedis' in data ? data.enableRedis : true,
|
||||
icon = data.icon || null;
|
||||
|
||||
await checkForPortBindingConflict(portBindings);
|
||||
await checkForPortBindingConflict(portBindings, {});
|
||||
|
||||
const queries = [];
|
||||
|
||||
@@ -955,7 +955,7 @@ async function updateWithConstraints(id, app, constraints) {
|
||||
if ('portBindings' in app) {
|
||||
const portBindings = app.portBindings || { };
|
||||
|
||||
await checkForPortBindingConflict(portBindings, id);
|
||||
await checkForPortBindingConflict(portBindings, { appId: id });
|
||||
|
||||
// replace entries by app id
|
||||
queries.push({ query: 'DELETE FROM appPortBindings WHERE appId = ?', args: [ id ] });
|
||||
|
||||
Reference in New Issue
Block a user