1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-16 12:55:14 +03:00

Fixed backup / restore, unified file name generation.

This commit is contained in:
Michael Keller 2017-03-03 13:35:24 +13:00
parent 954d33a8ef
commit 0926f64f3b
3 changed files with 47 additions and 35 deletions

View file

@ -163,18 +163,13 @@ function configuration_backup(callback) {
function save() {
var chosenFileEntry = null;
var accepts = [{
extensions: ['json']
}];
var prefix = 'betaflight_backup';
var suffix = 'json';
// generate timestamp for the backup file
var now = new Date().toISOString().split(".")[0];
// replace invalid filesystem characters
now = now.replace(new RegExp(':', 'g'), '_');
var filename = generateFilename(prefix, suffix);
// create or load the file
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: 'betaflight_backup_' + now + '.json', accepts: accepts}, function (fileEntry) {
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: filename, accepts: [{ extensions: [suffix] }]}, function (fileEntry) {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
return;
@ -241,7 +236,7 @@ function configuration_restore(callback) {
var chosenFileEntry = null;
var accepts = [{
extensions: ['txt']
extensions: ['json']
}];
// load up the file
@ -288,6 +283,7 @@ function configuration_restore(callback) {
return;
}
// validate
if (typeof configuration.generatedBy !== 'undefined' && compareVersions(configuration.generatedBy, CONFIGURATOR.backupFileMinVersionAccepted)) {
@ -295,7 +291,13 @@ function configuration_restore(callback) {
GUI.log(chrome.i18n.getMessage('backupFileUnmigratable'));
return;
}
if (configuration.BF_CONFIG.features._featureMask) {
var features = new Features(CONFIG);
features.setMask(configuration.BF_CONFIG.features._featureMask);
configuration.BF_CONFIG.features = features;
}
configuration_upload(configuration, callback);
} else {