From ab41462af3df6bdf80f637f9c3e516a476b7850a Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 27 Aug 2014 09:59:01 +0100 Subject: [PATCH] Ensure that savers invoke the callback --- core/modules/savers/download.js | 2 ++ core/modules/savers/fsosaver.js | 8 +++++--- core/modules/savers/manualdownload.js | 2 ++ core/modules/savers/msdownload.js | 2 ++ core/modules/savers/tiddlyie.js | 3 ++- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/modules/savers/download.js b/core/modules/savers/download.js index b84347723..ad23ecd11 100644 --- a/core/modules/savers/download.js +++ b/core/modules/savers/download.js @@ -38,6 +38,8 @@ DownloadSaver.prototype.save = function(text,method,callback) { document.body.appendChild(link); link.click(); document.body.removeChild(link); + // Callback that we succeeded + callback(null); return true; }; diff --git a/core/modules/savers/fsosaver.js b/core/modules/savers/fsosaver.js index d61235a95..37224e42a 100644 --- a/core/modules/savers/fsosaver.js +++ b/core/modules/savers/fsosaver.js @@ -33,14 +33,16 @@ FSOSaver.prototype.save = function(text,method,callback) { pathname = pathname.substr(1); // reconstruct UNC path pathname = "\\\\" + document.location.hostname + pathname; - } else return false; - + } else { + return false; + } // Save the file (as UTF-16) var fso = new ActiveXObject("Scripting.FileSystemObject"); var file = fso.OpenTextFile(pathname,2,-1,-1); - file.Write(text); file.Close(); + // Callback that we succeeded + callback(null); return true; }; diff --git a/core/modules/savers/manualdownload.js b/core/modules/savers/manualdownload.js index ae451d455..af9bcd743 100644 --- a/core/modules/savers/manualdownload.js +++ b/core/modules/savers/manualdownload.js @@ -25,6 +25,8 @@ ManualDownloadSaver.prototype.save = function(text,method,callback) { $tw.modal.display(downloadInstructionsTitle,{ downloadLink: "data:text/html," + encodeURIComponent(text) }); + // Callback that we succeeded + callback(null); return true; }; diff --git a/core/modules/savers/msdownload.js b/core/modules/savers/msdownload.js index 78fa9c140..6cb55c334 100644 --- a/core/modules/savers/msdownload.js +++ b/core/modules/savers/msdownload.js @@ -28,6 +28,8 @@ MsDownloadSaver.prototype.save = function(text,method,callback) { // Set up the link var blob = new Blob([text], {type: "text/html"}); window.navigator.msSaveBlob(blob,filename); + // Callback that we succeeded + callback(null); return true; }; diff --git a/core/modules/savers/tiddlyie.js b/core/modules/savers/tiddlyie.js index c04f8ec94..d6d49db45 100644 --- a/core/modules/savers/tiddlyie.js +++ b/core/modules/savers/tiddlyie.js @@ -35,9 +35,10 @@ TiddlyIESaver.prototype.save = function(text,method,callback) { // reconstruct UNC path pathname = "\\\\" + document.location.hostname + pathname; } else return false; - // Prompt the user to save the file window.TiddlyIE.save(pathname, text); + // Callback that we succeeded + callback(null); return true; } else { return false;