Fix purge invocations of new singletons

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2020-07-20 18:17:01 +01:00
parent dd972fd75e
commit d2a7d3b965

View File

@ -1,6 +1,9 @@
import * as Bluebird from 'bluebird'; import * as Bluebird from 'bluebird';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { appNotFoundMessage } from '../lib/messages'; import { appNotFoundMessage } from '../lib/messages';
import * as logger from '../logger';
import * as volumes from '../compose/volume-manager';
export function doRestart(applications, appId, force) { export function doRestart(applications, appId, force) {
const { _lockingIfNecessary, deviceState } = applications; const { _lockingIfNecessary, deviceState } = applications;
@ -31,7 +34,7 @@ export function doRestart(applications, appId, force) {
} }
export function doPurge(applications, appId, force) { export function doPurge(applications, appId, force) {
const { logger, _lockingIfNecessary, deviceState, volumes } = applications; const { _lockingIfNecessary, deviceState } = applications;
logger.logSystemMessage( logger.logSystemMessage(
`Purging data for app ${appId}`, `Purging data for app ${appId}`,
@ -72,16 +75,17 @@ export function doPurge(applications, appId, force) {
.finally(() => deviceState.triggerApplyTarget()); .finally(() => deviceState.triggerApplyTarget());
}), }),
) )
.tap(() => .then(() =>
logger.logSystemMessage('Purged data', { appId }, 'Purge data success'), logger.logSystemMessage('Purged data', { appId }, 'Purge data success'),
) )
.tapCatch((err) => .catch((err) => {
logger.logSystemMessage( logger.logSystemMessage(
`Error purging data: ${err}`, `Error purging data: ${err}`,
{ appId, error: err }, { appId, error: err },
'Purge data error', 'Purge data error',
), );
); throw err;
});
} }
export function serviceAction(action, serviceId, current, target, options) { export function serviceAction(action, serviceId, current, target, options) {