diff --git a/lib/utils/device/progress.ts b/lib/utils/device/progress.ts deleted file mode 100644 index f98418e2..00000000 --- a/lib/utils/device/progress.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2016-2017 Balena - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -import * as BalenaDeviceStatus from 'balena-device-status'; -import { Device } from 'balena-sdk'; - -export const getDeviceOsProgress = (device: Device) => { - if (!device.is_online) { - return null; - } - - const status = BalenaDeviceStatus.getStatus(device).key; - - if ( - status === BalenaDeviceStatus.status.UPDATING && - !!device.download_progress - ) { - return device.download_progress; - } - if ( - (status === BalenaDeviceStatus.status.CONFIGURING || - status === BalenaDeviceStatus.status.POST_PROVISIONING) && - device.provisioning_progress - ) { - return device.provisioning_progress; - } - - return 0; -}; diff --git a/lib/utils/patterns.ts b/lib/utils/patterns.ts index 4e128951..6797ffd3 100644 --- a/lib/utils/patterns.ts +++ b/lib/utils/patterns.ts @@ -279,7 +279,6 @@ export function awaitDevice(uuid: string) { export function awaitDeviceOsUpdate(uuid: string, targetOsVersion: string) { const balena = getBalenaSdk(); - const { getDeviceOsProgress } = require('./device/progress'); return balena.models.device.getName(uuid).then(deviceName => { const visuals = getVisuals(); @@ -291,8 +290,8 @@ export function awaitDeviceOsUpdate(uuid: string, targetOsVersion: string) { const poll = (): Bluebird => { return Bluebird.all([ balena.models.device.getOsUpdateStatus(uuid), - balena.models.device.get(uuid).then(getDeviceOsProgress), - ]).then(([osUpdateStatus, osUpdateProgress]) => { + balena.models.device.get(uuid, { $select: 'overall_progress' }), + ]).then(([osUpdateStatus, { overall_progress: osUpdateProgress }]) => { if (osUpdateStatus.status === 'done') { console.info( `The device ${deviceName} has been updated to v${targetOsVersion} and will restart shortly!`,