fix(writer): Use final size if it's not an estimation (#1587)

This avoids running into the "flashstate percentage above 100%" error again.

Change-Type: patch
Changelog-Entry: Prevent "percentage above 100%" errors on DMG images.
This commit is contained in:
Jonas Hermsmeier 2017-07-24 21:54:02 +02:00 committed by Juan Cruz Viotti
parent fa8f8151f6
commit 36664fb251
2 changed files with 5 additions and 5 deletions

View File

@ -157,7 +157,9 @@ module.exports = {
extension: fileExtensions.getLastFileExtension(imagePath),
stream: udif.createReadStream(imagePath),
size: {
original: options.size,
// FIXME(jhermsmeier): Originally `options.size`,
// See discussion in https://github.com/resin-io/etcher/pull/1587
original: size || options.size,
final: {
estimation: false,
value: size

View File

@ -81,14 +81,13 @@ describe('ImageStream: DMG', function() {
it('should return the correct metadata', function() {
const image = path.join(DMG_PATH, 'etcher-test-zlib.dmg');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
const compressedSize = fs.statSync(image).size;
return imageStream.getImageMetadata(image).then((metadata) => {
m.chai.expect(metadata).to.deep.equal({
path: image,
extension: 'dmg',
size: {
original: compressedSize,
original: uncompressedSize,
final: {
estimation: false,
value: uncompressedSize
@ -122,14 +121,13 @@ describe('ImageStream: DMG', function() {
it('should return the correct metadata', function() {
const image = path.join(DMG_PATH, 'etcher-test-raw.dmg');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
const compressedSize = fs.statSync(image).size;
return imageStream.getImageMetadata(image).then((metadata) => {
m.chai.expect(metadata).to.deep.equal({
path: image,
extension: 'dmg',
size: {
original: compressedSize,
original: uncompressedSize,
final: {
estimation: false,
value: uncompressedSize