diff --git a/src/app.js b/src/app.js index 1336256a29..89be8f816b 100644 --- a/src/app.js +++ b/src/app.js @@ -163,9 +163,7 @@ var run = function () { for (var i = 0; i < fileList.length; i++) { var name = fileList[i].name; if (!storage.exists(utils.fileKey(name)) || confirm('The file ' + name + ' already exists! Would you like to overwrite it?')) { - editor.uploadFile(fileList[i], function () { - updateFiles(); - }); + editor.uploadFile(fileList[i], updateFiles); } } diff --git a/src/app/editor.js b/src/app/editor.js index bb82550211..e7f2cd50dd 100644 --- a/src/app/editor.js +++ b/src/app/editor.js @@ -27,11 +27,12 @@ function Editor (loadingFromGist, storage) { this.uploadFile = function (file, callback) { var fileReader = new FileReader(); + var cacheName = utils.fileKey(file.name); - SOL_CACHE_FILE = utils.fileKey(file.name); fileReader.onload = function (e) { - storage.set(SOL_CACHE_FILE, e.target.result); - sessions[SOL_CACHE_FILE] = null; + storage.set(cacheName, e.target.result); + sessions[cacheName] = null; + SOL_CACHE_FILE = cacheName; callback(); }; fileReader.readAsText(file);