mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 02:39:49 +00:00
Prevent resin-write infinite loop
This commit is contained in:
parent
4acc85abb8
commit
4aefb15c70
@ -1,10 +1,7 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// http://coffeescript.org/documentation/docs/register.html
|
var os = require('../build/actions/os');
|
||||||
require('coffee-script/register');
|
var errors = require('../build/errors');
|
||||||
|
|
||||||
var os = require('../lib/actions/os.coffee');
|
|
||||||
var errors = require('../lib/errors');
|
|
||||||
|
|
||||||
// TODO: Do some error handling when image or device are incorrect
|
// TODO: Do some error handling when image or device are incorrect
|
||||||
|
|
||||||
@ -12,7 +9,8 @@ os.install.action({
|
|||||||
image: process.argv[2],
|
image: process.argv[2],
|
||||||
device: process.argv[3]
|
device: process.argv[3]
|
||||||
}, {
|
}, {
|
||||||
yes: true
|
yes: true,
|
||||||
|
fromScript: true
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
return errors.handle(error);
|
return errors.handle(error);
|
||||||
});
|
});
|
||||||
|
@ -120,7 +120,10 @@
|
|||||||
}
|
}
|
||||||
], function(error) {
|
], function(error) {
|
||||||
var resinWritePath, windosu;
|
var resinWritePath, windosu;
|
||||||
if (os.platform() === 'win32' && (error != null) && (error.code === 'EPERM' || error.code === 'EACCES')) {
|
if (error == null) {
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
if (_.all([os.platform() === 'win32', error.code === 'EPERM' || error.code === 'EACCES', !options.fromScript])) {
|
||||||
windosu = require('windosu');
|
windosu = require('windosu');
|
||||||
resinWritePath = "\"" + (path.join(__dirname, '..', '..', 'bin', 'resin-write')) + "\"";
|
resinWritePath = "\"" + (path.join(__dirname, '..', '..', 'bin', 'resin-write')) + "\"";
|
||||||
return windosu.exec("\"" + process.argv[0] + "\" " + resinWritePath + " \"" + params.image + "\" \"" + params.device + "\"");
|
return windosu.exec("\"" + process.argv[0] + "\" " + resinWritePath + " \"" + params.image + "\" \"" + params.device + "\"");
|
||||||
|
@ -152,9 +152,18 @@ exports.install =
|
|||||||
diskio.writeStream(params.device, imageFileStream, callback)
|
diskio.writeStream(params.device, imageFileStream, callback)
|
||||||
|
|
||||||
], (error) ->
|
], (error) ->
|
||||||
if os.platform() is 'win32' and error? and (error.code is 'EPERM' or error.code is 'EACCES')
|
return done() if not error?
|
||||||
windosu = require('windosu')
|
|
||||||
|
|
||||||
|
if _.all [
|
||||||
|
os.platform() is 'win32'
|
||||||
|
error.code is 'EPERM' or error.code is 'EACCES'
|
||||||
|
|
||||||
|
# Prevent re-running resin-write infinitely
|
||||||
|
# If we have an EPERM or EACCES even after running
|
||||||
|
# windosu, we throw it as there is not much we can do
|
||||||
|
not options.fromScript
|
||||||
|
]
|
||||||
|
windosu = require('windosu')
|
||||||
# Need to escape every path to avoid errors
|
# Need to escape every path to avoid errors
|
||||||
resinWritePath = "\"#{path.join(__dirname, '..', '..', 'bin', 'resin-write')}\""
|
resinWritePath = "\"#{path.join(__dirname, '..', '..', 'bin', 'resin-write')}\""
|
||||||
windosu.exec("\"#{process.argv[0]}\" #{resinWritePath} \"#{params.image}\" \"#{params.device}\"")
|
windosu.exec("\"#{process.argv[0]}\" #{resinWritePath} \"#{params.image}\" \"#{params.device}\"")
|
||||||
|
Loading…
Reference in New Issue
Block a user