mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 17:56:57 +00:00
Fix temporary os download output option in device init
This commit is contained in:
parent
ae8c941bfe
commit
3bc71577b5
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var _, async, commandOptions, osAction, path, resin, vcs, visuals;
|
var _, async, commandOptions, osAction, path, resin, tmp, vcs, visuals;
|
||||||
|
|
||||||
_ = require('lodash-contrib');
|
_ = require('lodash-contrib');
|
||||||
|
|
||||||
@ -13,6 +13,10 @@
|
|||||||
|
|
||||||
vcs = require('resin-vcs');
|
vcs = require('resin-vcs');
|
||||||
|
|
||||||
|
tmp = require('tmp');
|
||||||
|
|
||||||
|
tmp.setGracefulCleanup();
|
||||||
|
|
||||||
commandOptions = require('./command-options');
|
commandOptions = require('./command-options');
|
||||||
|
|
||||||
osAction = require('./os');
|
osAction = require('./os');
|
||||||
@ -137,10 +141,27 @@
|
|||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
options.yes = confirmed;
|
options.yes = confirmed;
|
||||||
return osAction.download.action(params, options, callback);
|
return tmp.file({
|
||||||
}, function(outputFile, callback) {
|
prefix: 'resin-image-',
|
||||||
|
postfix: '.img'
|
||||||
|
}, callback);
|
||||||
|
}, function(tmpPath, tmpFd, cleanupCallback, callback) {
|
||||||
|
options.output = tmpPath;
|
||||||
|
return osAction.download.action(params, options, function(error, outputFile) {
|
||||||
|
if (error != null) {
|
||||||
|
return callback(error);
|
||||||
|
}
|
||||||
|
return callback(null, outputFile, cleanupCallback);
|
||||||
|
});
|
||||||
|
}, function(outputFile, cleanupCallback, callback) {
|
||||||
params.image = outputFile;
|
params.image = outputFile;
|
||||||
return osAction.install.action(params, options, callback);
|
return osAction.install.action(params, options, function(error) {
|
||||||
|
if (error != null) {
|
||||||
|
return callback(error);
|
||||||
|
}
|
||||||
|
cleanupCallback();
|
||||||
|
return callback();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
], done);
|
], done);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,11 @@ async = require('async')
|
|||||||
resin = require('resin-sdk')
|
resin = require('resin-sdk')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
vcs = require('resin-vcs')
|
vcs = require('resin-vcs')
|
||||||
|
tmp = require('tmp')
|
||||||
|
|
||||||
|
# Cleanup the temporary files even when an uncaught exception occurs
|
||||||
|
tmp.setGracefulCleanup()
|
||||||
|
|
||||||
commandOptions = require('./command-options')
|
commandOptions = require('./command-options')
|
||||||
osAction = require('./os')
|
osAction = require('./os')
|
||||||
|
|
||||||
@ -210,10 +215,23 @@ exports.init =
|
|||||||
(confirmed, callback) ->
|
(confirmed, callback) ->
|
||||||
return done() if not confirmed
|
return done() if not confirmed
|
||||||
options.yes = confirmed
|
options.yes = confirmed
|
||||||
osAction.download.action(params, options, callback)
|
|
||||||
|
|
||||||
(outputFile, callback) ->
|
tmp.file
|
||||||
|
prefix: 'resin-image-'
|
||||||
|
postfix: '.img'
|
||||||
|
, callback
|
||||||
|
|
||||||
|
(tmpPath, tmpFd, cleanupCallback, callback) ->
|
||||||
|
options.output = tmpPath
|
||||||
|
osAction.download.action params, options, (error, outputFile) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
return callback(null, outputFile, cleanupCallback)
|
||||||
|
|
||||||
|
(outputFile, cleanupCallback, callback) ->
|
||||||
params.image = outputFile
|
params.image = outputFile
|
||||||
osAction.install.action(params, options, callback)
|
osAction.install.action params, options, (error) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
cleanupCallback()
|
||||||
|
return callback()
|
||||||
|
|
||||||
], done)
|
], done)
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
"resin-sdk": "^1.2.0",
|
"resin-sdk": "^1.2.0",
|
||||||
"resin-settings-client": "^1.0.0",
|
"resin-settings-client": "^1.0.0",
|
||||||
"resin-vcs": "^1.2.0",
|
"resin-vcs": "^1.2.0",
|
||||||
|
"tmp": "^0.0.25",
|
||||||
"underscore.string": "~2.4.0",
|
"underscore.string": "~2.4.0",
|
||||||
"update-notifier": "^0.3.1"
|
"update-notifier": "^0.3.1"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user