Turns out that even by using `process.exit(1)`, the electron main
process doesn't exit instantly, but continues executing code.
This causes electron to throw on `electron.globalShortcut` because this
functionality is not available given that we didn't create a renderer
view.
Fixes: https://github.com/resin-io/etcher/issues/215
This error was reported by TrackJS various times:
```
TypeError: Cannot read property 'length' of undefined
at EventEmitter.<anonymous> (file:///Users/jviotti/Projects/resin/etcher/lib/browser/app.js:104:15)
at emitOne (events.js:77:13)
at EventEmitter.emit (events.js:169:7)
at /Users/jviotti/Projects/resin/etcher/lib/browser/modules/drive-scanner.js:131:17
at processQueue (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:15616:28)
at /Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:15632:27
at Scope.$eval (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:16884:28)
at Scope.$digest (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:16700:31)
at /Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:16923:26
at completeOutstandingRequest (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:5825:10),
```
The error refers to the following line in `app.js`:
```js
if (drives.length === 1 && self.selection.hasImage()) {
```
Which indicates that the array of detected drives returned to the main
controller is `undefined` for some reason.
The problem resides in the `.scan()` method of `DriveScannerService`:
```js
this.scan = function() {
return $q.when(drives.listRemovable()).catch(dialog.showError);
};
```
When an error is thrown when scanning the drives, the `.catch()` block
is called. This means that the error is not propagated to the outer code
and the promise resolves with `undefined`.
The solution is to move `.catch()` to the place `.scan()` is called,
instead of making use of it in the low-level parts of the process.
Previously, the burn state lived in the controller, however if the user
moved to another page (the settings page for example) and then returned,
the progress state would be lost, leading to a broken progress bar.
Fixes: https://github.com/resin-io/etcher/issues/190
This service provides an easy-to-use and safe (regarding to memory
leaks) way to emit data from services to controllers.
This component will be used in `ImageWriterService` to emit the progress
state instead of accepting an `onProgress` callback.
Our `package.json` contains a custom `displayName` property which equals
"Etcher" at the time of this writing.
This PR makes use of this property directly instead of hardcoding
"Etcher" in some places.
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 will be the case when the dialog accepts zip files. If the selected
zip image is invalid, the module will display an error and resolve
`undefined`.
`.open()` was previously exposed in the `AppController`, however after
the router refactoring, this controller is no longer instantiated on the
footer, and therefore the links that live there stopped working.
Later versions make use of shell commands over the internal contents of
the module causing errors when the application is packaged as an
`asar`.
This issue is being fixed here: https://github.com/jorangreef/sudo-prompt/issues/10