Skip to content

Commit

Permalink
feat(gui): Display image size when drive too small
Browse files Browse the repository at this point in the history
This adds a display of the determined image size to the
drive label when the drive has been determined to be too small.

Change-Type: patch
Changelog-Entry: Display image size for comparison if drive is too small
  • Loading branch information
jhermsmeier committed Oct 25, 2017
1 parent 02f7a5f commit 1166d7c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/shared/drive-constraints.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

const _ = require('lodash')
const pathIsInside = require('path-is-inside')
const prettyBytes = require('pretty-bytes')

/**
* @summary The default unknown size for things such as images and drives
Expand Down Expand Up @@ -281,7 +282,7 @@ exports.COMPATIBILITY_STATUS_MESSAGES = {
* @description
* The drive is too small for the image.
*/
TOO_SMALL: 'Too Small For Image',
TOO_SMALL: 'Too Small For Image by',

/**
* @property {String} LOCKED
Expand Down Expand Up @@ -376,9 +377,11 @@ exports.getDriveImageCompatibilityStatuses = (drive, image) => {
message: exports.COMPATIBILITY_STATUS_MESSAGES.LOCKED
})
} else if (!_.isNil(drive) && !_.isNil(drive.size) && !exports.isDriveLargeEnough(drive, image)) {
const imageSize = _.get(image, [ 'size', 'final', 'estimation' ]) ? image.size.original : image.size.final.value
const relativeBytes = imageSize - drive.size
statusList.push({
type: exports.COMPATIBILITY_STATUS_TYPES.ERROR,
message: exports.COMPATIBILITY_STATUS_MESSAGES.TOO_SMALL
message: `${exports.COMPATIBILITY_STATUS_MESSAGES.TOO_SMALL} ${prettyBytes(relativeBytes)}`
})
} else {
if (exports.isSystemDrive(drive)) {
Expand Down

0 comments on commit 1166d7c

Please sign in to comment.