Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/sc 133701/tachyon setup is rehashing an already hashed #793

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/cmd/setup-tachyon.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = class SetupTachyonCommands extends CLICommandBase {

async setup({ skip_flashing_os: skipFlashingOs, version, load_config: loadConfig, save_config: saveConfig }) {
try {
const loadedFromFile = !!loadConfig;
this._showWelcomeMessage();
this._formatAndDisplaySteps("Okay—first up! Checking if you're logged in...", 1);

Expand Down Expand Up @@ -98,7 +99,11 @@ module.exports = class SetupTachyonCommands extends CLICommandBase {
const { path: configBlobPath, configBlob } = await this._runStepWithTiming(
'Creating the configuration file to write to the Tachyon device...',
6,
() => this._createConfigBlob({ registrationCode, ...config })
() => this._createConfigBlob({
loadedFromFile,
registrationCode,
...config
})
);
const xmlPath = await this._createXmlFile(configBlobPath);
// Save the config file if requested
Expand All @@ -118,7 +123,7 @@ module.exports = class SetupTachyonCommands extends CLICommandBase {
() => this._flash({
files: [packagePath, xmlPath],
skipFlashingOs,
silent: !!loadConfig
silent: loadedFromFile
})
);

Expand Down Expand Up @@ -405,7 +410,7 @@ Welcome to the Particle Tachyon setup! This interactive command:
}
];
const res = await this.ui.prompt(questions);
const { password } = await this.ui.promptPasswordWithConfirmation({
const password = await this.ui.promptPasswordWithConfirmation({
customMessage: 'Enter your WiFi password:',
customConfirmationMessage: 'Re-enter your WiFi password:'
});
Expand Down Expand Up @@ -453,11 +458,11 @@ Welcome to the Particle Tachyon setup! This interactive command:
return data.registration_code;
}

async _createConfigBlob({ registrationCode, systemPassword, wifi, sshPublicKey, productId }) {
async _createConfigBlob({ loadedFromFile = false, registrationCode, systemPassword, wifi, sshPublicKey, productId }) {
// Format the config and registration code into a config blob (JSON file, prefixed by the file size)
const config = {
registrationCode: registrationCode,
systemPassword : this._generateShadowCompatibleHash(systemPassword),
systemPassword : loadedFromFile ? systemPassword : this._generateShadowCompatibleHash(systemPassword)
};

if (wifi) {
Expand Down