Merge pull request #117 from Denton-L/upload-fix-on-72

Upload fix, rebased onto #72
pull/1/head
chriseth 9 years ago committed by GitHub
commit 0c97e001e3
  1. 4
      src/app.js
  2. 7
      src/app/editor.js

@ -163,9 +163,7 @@ var run = function () {
for (var i = 0; i < fileList.length; i++) { for (var i = 0; i < fileList.length; i++) {
var name = fileList[i].name; var name = fileList[i].name;
if (!storage.exists(utils.fileKey(name)) || confirm('The file ' + name + ' already exists! Would you like to overwrite it?')) { if (!storage.exists(utils.fileKey(name)) || confirm('The file ' + name + ' already exists! Would you like to overwrite it?')) {
editor.uploadFile(fileList[i], function () { editor.uploadFile(fileList[i], updateFiles);
updateFiles();
});
} }
} }

@ -27,11 +27,12 @@ function Editor (loadingFromGist, storage) {
this.uploadFile = function (file, callback) { this.uploadFile = function (file, callback) {
var fileReader = new FileReader(); var fileReader = new FileReader();
var cacheName = utils.fileKey(file.name);
SOL_CACHE_FILE = utils.fileKey(file.name);
fileReader.onload = function (e) { fileReader.onload = function (e) {
storage.set(SOL_CACHE_FILE, e.target.result); storage.set(cacheName, e.target.result);
sessions[SOL_CACHE_FILE] = null; sessions[cacheName] = null;
SOL_CACHE_FILE = cacheName;
callback(); callback();
}; };
fileReader.readAsText(file); fileReader.readAsText(file);

Loading…
Cancel
Save