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 425f180
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion 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 @@ -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 425f180

Please sign in to comment.