fix(GUI): check drive size against uncompressed image size (#582)

We were currently checking if a drive was large enough for an image by checking
the image file size, completely ignoring compression. This results on a small
chance of the uncompressed image not actually fitting in the drive, and
throwing more weird errors later on.

In order to mitigate this, we use the new `.getEstimatedFinalSize()` function
from `etcher-image-stream`, which returns the uncompressed size in the case of
compressed images.

We needed to update the build script for OS X to configure NPM correctly,
otherwise `lzma-native` throws some errors due to an ABI V8 incompatibility
issue.

Fixes: #571
See: https://github.com/addaleax/lzma-native/issues/25
Change-Type: patch
Changelog-Entry: Check if drive is large enough using the final uncompressed size of the image.
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
Juan Cruz Viotti 2016-07-19 23:17:09 -04:00 committed by GitHub
parent ef96ae86a0
commit 1762ea629f
3 changed files with 930 additions and 582 deletions

View File

@ -17,7 +17,7 @@
'use strict';
const _ = require('lodash');
const fs = require('fs');
const imageStream = require('etcher-image-stream');
const electron = require('electron');
module.exports = function($q, SupportedFormatsModel) {
@ -71,17 +71,12 @@ module.exports = function($q, SupportedFormatsModel) {
return resolve();
}
fs.stat(imagePath, (error, stats) => {
if (error) {
return reject(error);
}
imageStream.getEstimatedFinalSize(imagePath).then((estimatedSize) => {
return resolve({
path: imagePath,
size: stats.size
size: estimatedSize
});
});
}).catch(reject);
});
});
};

1497
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,7 @@
"chalk": "^1.1.3",
"drivelist": "^3.2.2",
"electron-is-running-in-asar": "^1.0.0",
"etcher-image-stream": "^2.3.0",
"etcher-image-stream": "^2.5.2",
"etcher-image-write": "^5.0.3",
"etcher-latest-version": "^1.0.0",
"file-tail": "^0.3.0",