mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-25 12:16:37 +00:00
Fix sporadic Cannot read property 'then' of undefined
This error happened when trying to burn an image when there is already a burn in progress. Fixes: https://github.com/resin-io/resin-etcher/issues/96
This commit is contained in:
parent
9d68199ecd
commit
111529ee71
@ -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);
|
||||
|
@ -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