mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-24 11:46:31 +00:00
Merge pull request #120 from resin-io/fix/96/then-of-undefined
Fix sporadic Cannot read property 'then' of undefined
This commit is contained in:
commit
0b0c3dc9fa
@ -114,10 +114,8 @@ imageWriter.service('ImageWriterService', function($q, $timeout) {
|
||||
* });
|
||||
*/
|
||||
this.burn = function(image, drive, onProgress) {
|
||||
|
||||
// Avoid writing more than once
|
||||
if (self.isBurning()) {
|
||||
return;
|
||||
return $q.reject(new Error('There is already a burn in progress'));
|
||||
}
|
||||
|
||||
self.setBurning(true);
|
||||
|
@ -5,7 +5,7 @@
|
||||
<dom-module id="hero-progress-button">
|
||||
<template>
|
||||
<style>
|
||||
:host:not([percentage="0"]) {
|
||||
:host[active="true"] {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@ -39,6 +39,9 @@
|
||||
Polymer({
|
||||
is: 'hero-progress-button',
|
||||
properties: {
|
||||
active: {
|
||||
type: Boolean
|
||||
},
|
||||
disabled: {
|
||||
type: String
|
||||
},
|
||||
|
@ -78,7 +78,7 @@
|
||||
<hero-badge class="block space-vertical-medium" ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()">3</hero-badge>
|
||||
|
||||
<div class="space-vertical-large">
|
||||
<hero-progress-button percentage="{{ app.state.progress }}" active="{{ app.writer.isBurning() }}"
|
||||
<hero-progress-button percentage="{{ app.state.progress }}" ng-attr-active="{{ app.writer.isBurning() }}"
|
||||
ng-click="app.burn(app.selection.getImage(), app.selection.getDrive())"
|
||||
ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()">
|
||||
<span ng-show="app.state.progress == 100 && app.writer.isBurning()">Finishing...</span>
|
||||
|
@ -84,6 +84,20 @@ describe('Browser: ImageWriter', function() {
|
||||
m.chai.expect(this.performWriteStub).to.have.been.calledOnce;
|
||||
});
|
||||
|
||||
it('should reject the second burn attempt', function() {
|
||||
ImageWriterService.burn('foo.img', '/dev/disk2');
|
||||
|
||||
let rejectError = null;
|
||||
ImageWriterService.burn('foo.img', '/dev/disk2').catch(function(error) {
|
||||
rejectError = error;
|
||||
});
|
||||
|
||||
$rootScope.$apply();
|
||||
|
||||
m.chai.expect(rejectError).to.be.an.instanceof(Error);
|
||||
m.chai.expect(rejectError.message).to.equal('There is already a burn in progress');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('given an unsuccesful write', function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user