diff --git a/js/core.js b/js/core.js index 2e42f3e6..b6835e49 100644 --- a/js/core.js +++ b/js/core.js @@ -556,6 +556,21 @@ define( }); version = "v2"; } + + // Upgrade from v2 to v3 + if(version == "v2") { + var fileIndexList = _.compact(localStorage["file.list"].split(";")); + _.each(fileIndexList, function(fileIndex) { + if(!_.has(localStorage, fileIndex + ".sync")) { + localStorage.removeItem(fileIndex + ".title"); + localStorage.removeItem(fileIndex + ".publish"); + localStorage.removeItem(fileIndex + ".content"); + localStorage["file.list"] = localStorage["file.list"].replace(";" + + fileIndex + ";", ";"); + } + }); + version = "v3"; + } localStorage["version"] = version; } // Setup the localStorage when starting diff --git a/js/file-manager.js b/js/file-manager.js index 902fc76f..e4ed4c6f 100644 --- a/js/file-manager.js +++ b/js/file-manager.js @@ -89,17 +89,17 @@ define(["jquery", "core", "synchronizer", "publisher", "underscore"], // Remove synchronized locations var syncIndexList = _.compact(localStorage[fileIndex + ".sync"].split(";")); - localStorage.removeItem(fileIndex + ".sync"); _.each(syncIndexList, function(syncIndex) { fileManager.removeSync(syncIndex); }); + localStorage.removeItem(fileIndex + ".sync"); // Remove publish locations var publishIndexList = _.compact(localStorage[fileIndex + ".publish"].split(";")); - localStorage.removeItem(fileIndex + ".publish"); _.each(publishIndexList, function(publishIndex) { fileManager.removePublish(publishIndex); }); + localStorage.removeItem(fileIndex + ".publish"); localStorage["file.list"] = localStorage["file.list"].replace(";" + fileIndex + ";", ";");