mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-17 08:16:32 +00:00
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:
parent
fa8f8151f6
commit
36664fb251
@ -157,7 +157,9 @@ module.exports = {
|
|||||||
extension: fileExtensions.getLastFileExtension(imagePath),
|
extension: fileExtensions.getLastFileExtension(imagePath),
|
||||||
stream: udif.createReadStream(imagePath),
|
stream: udif.createReadStream(imagePath),
|
||||||
size: {
|
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: {
|
final: {
|
||||||
estimation: false,
|
estimation: false,
|
||||||
value: size
|
value: size
|
||||||
|
@ -81,14 +81,13 @@ describe('ImageStream: DMG', function() {
|
|||||||
it('should return the correct metadata', function() {
|
it('should return the correct metadata', function() {
|
||||||
const image = path.join(DMG_PATH, 'etcher-test-zlib.dmg');
|
const image = path.join(DMG_PATH, 'etcher-test-zlib.dmg');
|
||||||
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
|
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
|
||||||
const compressedSize = fs.statSync(image).size;
|
|
||||||
|
|
||||||
return imageStream.getImageMetadata(image).then((metadata) => {
|
return imageStream.getImageMetadata(image).then((metadata) => {
|
||||||
m.chai.expect(metadata).to.deep.equal({
|
m.chai.expect(metadata).to.deep.equal({
|
||||||
path: image,
|
path: image,
|
||||||
extension: 'dmg',
|
extension: 'dmg',
|
||||||
size: {
|
size: {
|
||||||
original: compressedSize,
|
original: uncompressedSize,
|
||||||
final: {
|
final: {
|
||||||
estimation: false,
|
estimation: false,
|
||||||
value: uncompressedSize
|
value: uncompressedSize
|
||||||
@ -122,14 +121,13 @@ describe('ImageStream: DMG', function() {
|
|||||||
it('should return the correct metadata', function() {
|
it('should return the correct metadata', function() {
|
||||||
const image = path.join(DMG_PATH, 'etcher-test-raw.dmg');
|
const image = path.join(DMG_PATH, 'etcher-test-raw.dmg');
|
||||||
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
|
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
|
||||||
const compressedSize = fs.statSync(image).size;
|
|
||||||
|
|
||||||
return imageStream.getImageMetadata(image).then((metadata) => {
|
return imageStream.getImageMetadata(image).then((metadata) => {
|
||||||
m.chai.expect(metadata).to.deep.equal({
|
m.chai.expect(metadata).to.deep.equal({
|
||||||
path: image,
|
path: image,
|
||||||
extension: 'dmg',
|
extension: 'dmg',
|
||||||
size: {
|
size: {
|
||||||
original: compressedSize,
|
original: uncompressedSize,
|
||||||
final: {
|
final: {
|
||||||
estimation: false,
|
estimation: false,
|
||||||
value: uncompressedSize
|
value: uncompressedSize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user