diff --git a/src/js/messaging.js b/src/js/messaging.js index c8b47c20a..f99bfa8cd 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -776,15 +776,12 @@ var backupUserData = function(callback) { var filename = vAPI.i18n('aboutBackupFilename') .replace('{{datetime}}', µb.dateNowToSensibleString()) .replace(/ +/g, '_'); - - vAPI.download({ - 'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(userData, null, ' ')), - 'filename': filename - }); µb.restoreBackupSettings.lastBackupFile = filename; µb.restoreBackupSettings.lastBackupTime = Date.now(); vAPI.storage.set(µb.restoreBackupSettings); - getLocalData(callback); + getLocalData(function(localData) { + callback({ localData: localData, userData: userData }); + }); }; µb.assets.get(µb.userFiltersPath, onUserFiltersReady); diff --git a/src/js/settings.js b/src/js/settings.js index 165829559..c7e24297a 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -1,7 +1,7 @@ /******************************************************************************* uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2016 Raymond Hill + Copyright (C) 2014-2017 Raymond Hill This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -105,7 +105,20 @@ var startImportFilePicker = function() { /******************************************************************************/ var exportToFile = function() { - messaging.send('dashboard', { what: 'backupUserData' }, onLocalDataReceived); + messaging.send('dashboard', { what: 'backupUserData' }, function(response) { + if ( + response instanceof Object === false || + response.userData instanceof Object === false + ) { + return; + } + vAPI.download({ + 'url': 'data:text/plain;charset=utf-8,' + + encodeURIComponent(JSON.stringify(response.userData, null, ' ')), + 'filename': response.localData.lastBackupFile + }); + onLocalDataReceived(response.localData); + }); }; /******************************************************************************/