This commit is contained in:
gorhill 2017-04-04 16:45:50 -04:00
parent b3d210c866
commit 510eba6bc4
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 18 additions and 8 deletions

View File

@ -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);

View File

@ -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);
});
};
/******************************************************************************/