xiongtong3 / switchy

Automatically exported from code.google.com/p/switchy
0 stars 0 forks source link

The restore backup do nothing #205

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When that most important working code in the restoreBackup was commented?

function restoreBackup() {
        var txtBackupFilePath = $("#txtBackupFilePath");
        if (txtBackupFilePath.hasClass("initial") || txtBackupFilePath.val().trim().length == 0) {
                InfoTip.alertI18n("message_selectBackupFile");
                txtBackupFilePath.focus();
                return;
        }
        var backupFilePath = txtBackupFilePath.val();
        var backupData = undefined;

        if (backupFilePath.substr(0, 7) == "http://" || backupFilePath.substr(0, 8) == "https://") {
                $.ajax({
                        async: false,
                        url: backupFilePath,
                        success: function(data, textStatus){
                                if (data.length <= 1024 * 50) // bigger than 50 KB
                                        backupData = data;
                                else
                                        Logger.log("Too big backup file!", Logger.Types.error);
                        },
                        error: function(request, textStatus, thrownError){
                                Logger.log("Error downloading the backup file!", Logger.Types.warning);
                        },
                        dataType: "text",
                        cache: false,
                        timeout: 10000
                });     
        }
        else {
                try {
                        backupData = extension.plugin.readFile(backupFilePath);
                } catch (e) {
                        Logger.log("Oops! Can't read the backup file, " + e.toString(), Logger.Types.error);
                        InfoTip.alertI18n("message_cannotReadOptionsBackup");
                        return;
                }
        }

        if (!backupData || backupData.trim().length == 0) {
                InfoTip.alertI18n("message_cannotRestoreOptionsBackup");
                return;
        }

        var options;
        try {
                backupData = $.base64Decode(backupData);
                options = JSON.parse(backupData);
        } catch (e) {
                Logger.log("Oops! Can't restore from this backup file. The backup file is corrupted or invalid, " + e.toString(), Logger.Types.error);
                InfoTip.alertI18n("message_cannotRestoreOptionsBackup");
                return;
        }

        if (!InfoTip.confirmI18n("message_restoreOptionsBackup"))
                return;

//      for (var optionName in options)
//              localStorage[optionName] = options[optionName];
//      
//      Settings.setValue("ruleListEnabled", false); // for security concerns

        InfoTip.alertI18n("message_successRestoreOptionsBackup");

//      window.location.reload();
}

Operating system:
All | Windows | Mac | Linux

Error Log:
copy it from "chrome-
extension://caehdcpeofiiigpdhbabniblemipncjj/console.html"

Please provide any additional information below. Attach a screenshot if
possible.

Original issue reported on code.google.com by liumengj...@gmail.com on 14 Aug 2010 at 2:01

GoogleCodeExporter commented 9 years ago
seems duplicate of bug 102, comment 7, in short regression in 1.6:

https://code.google.com/p/switchy/issues/detail?id=102#c7

Original comment by elan.ruu...@gmail.com on 9 Jul 2011 at 2:55