mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-29 06:06:33 +00:00
Add support for zip images in select image dialog
The "Select Image" dialog now permits the user selecting zip files. Once the zip file is selected, `resin-zip-image` scans the archive to ensure its validity. If its not valid, an error alert is shown and nothing is selected.
This commit is contained in:
parent
3e352d4224
commit
a5322950da
@ -18,6 +18,7 @@
|
||||
|
||||
const electron = require('electron');
|
||||
const Bluebird = require('bluebird');
|
||||
const zipImage = require('resin-zip-image');
|
||||
|
||||
/**
|
||||
* @summary Open an image selection dialog
|
||||
@ -25,7 +26,10 @@ const Bluebird = require('bluebird');
|
||||
* @public
|
||||
*
|
||||
* @description
|
||||
* Notice that by image, we mean *.img/*.iso files.
|
||||
* Notice that by image, we mean *.img/*.iso/*.zip files.
|
||||
*
|
||||
* If the user selects an invalid zip image, an error alert
|
||||
* is shown, and the promise resolves `undefined`.
|
||||
*
|
||||
* @fulfil {String} - selected image
|
||||
* @returns {Promise};
|
||||
@ -41,15 +45,27 @@ exports.selectImage = function() {
|
||||
properties: [ 'openFile' ],
|
||||
filters: [
|
||||
{
|
||||
name: 'IMG/ISO',
|
||||
name: 'IMG/ISO/ZIP',
|
||||
extensions: [
|
||||
'zip',
|
||||
'img',
|
||||
'iso'
|
||||
]
|
||||
}
|
||||
]
|
||||
}, resolve);
|
||||
}).get(0);
|
||||
}).get(0).then(function(file) {
|
||||
if (zipImage.isZip(file) && !zipImage.isValidZipImage(file)) {
|
||||
electron.dialog.showErrorBox(
|
||||
'Invalid zip image',
|
||||
'Etcher can only open Zip archives that contain exactly one image file inside.'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return file;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@
|
||||
"lodash": "^4.5.1",
|
||||
"ngstorage": "^0.3.10",
|
||||
"resin-image-write": "^2.0.5",
|
||||
"resin-zip-image": "^1.1.0",
|
||||
"resin-zip-image": "^1.1.1",
|
||||
"sudo-prompt": "^2.2.0",
|
||||
"trackjs": "^2.1.16",
|
||||
"umount": "^1.1.1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user