Zotero.File.putContentsAsync() fixes

Breakage from e6ccca3230
This commit is contained in:
Dan Stillman 2015-04-13 02:39:36 -04:00
parent 915542e696
commit 7b72d47070

View file

@ -328,7 +328,7 @@ Zotero.File = new function(){
*/ */
this.putContentsAsync = function putContentsAsync(path, data, charset) { this.putContentsAsync = function putContentsAsync(path, data, charset) {
if (path instanceof Ci.nsIFile) { if (path instanceof Ci.nsIFile) {
path = this.fileToPath(path); path = path.path;
} }
if (typeof data == 'string' && (!charset || charset.toLowerCase() == 'utf-8')) { if (typeof data == 'string' && (!charset || charset.toLowerCase() == 'utf-8')) {
@ -355,7 +355,7 @@ Zotero.File = new function(){
} }
var deferred = Zotero.Promise.defer(), var deferred = Zotero.Promise.defer(),
ostream = FileUtils.openSafeFileOutputStream(file); ostream = FileUtils.openSafeFileOutputStream(path);
NetUtil.asyncCopy(data, ostream, function(inputStream, status) { NetUtil.asyncCopy(data, ostream, function(inputStream, status) {
if (!Components.isSuccessCode(status)) { if (!Components.isSuccessCode(status)) {
deferred.reject(new Components.Exception("File write operation failed", status)); deferred.reject(new Components.Exception("File write operation failed", status));