diff options
author | Jagua | 2015-02-16 00:21:12 +0900 |
---|---|---|
committer | Jagua | 2015-02-16 00:21:12 +0900 |
commit | 0e98b023e7cd0448a2ad4134dd0c382d76c85cf1 (patch) | |
tree | 9d420d7c7ce5343fcaff2e2a9e38ed54aadbd0ce /stella.js | |
parent | ba6103661a2807c0e615e28a4566fb27537debd3 (diff) | |
download | vimperator-plugins-0e98b023e7cd0448a2ad4134dd0c382d76c85cf1.tar.bz2 |
don't use nsIDownloadManager. (use Downloads.jsm)
Diffstat (limited to 'stella.js')
-rw-r--r-- | stella.js | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -313,14 +313,12 @@ Thanks: return mis; } - let dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager); - let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist); let file; if (filepath) { file = io.File(io.expandPath(filepath)); } else { - file = dm.userDownloadsDirectory; + file = io.File(FileUtils.getDir("DfltDwnld", [""])); } if (file.exists() && file.isDirectory() && title) @@ -329,12 +327,15 @@ Thanks: if (file.exists()) return U.echoError('The file already exists! -> ' + file.path); - file = makeFileURI(file); - - let dl = dm.addDownload(0, U.makeURL(url, null, null), file, title, null, null, null, null, wbp); - wbp.progressListener = dl; - wbp.persistFlags |= wbp.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION; - wbp.saveURI(U.makeURL(url), null, null, postData && makePostStream(postData), null, file); + Task.spawn(function () { + if (postData) { + yield U.httpRequest(url, postData, function (xhr) { + file.write(xhr.response); + }); + } else { + yield Downloads.fetch(url, file); + } + }).then(null, Cu.reportError); return file; }, |