commit 55d27273fb9b80ca17d663a025cbbf152ed54926
parent 4fd65fec4cf13b6c4e57a637ab400422209ef46e
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 31 May 2015 23:01:34 -0400
TextEncoder is no longer required for OS.File.writeAtomic()
Diffstat:
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js
@@ -340,29 +340,20 @@ Zotero.File = new function(){
path = path.path;
}
- if (typeof data == 'string' && (!charset || charset.toLowerCase() == 'utf-8')) {
- let encoder = new TextEncoder();
- let array = encoder.encode(data);
+ if (typeof data == 'string') {
return Zotero.Promise.resolve(OS.File.writeAtomic(
path,
- array,
+ data,
{
tmpPath: OS.Path.join(
Zotero.getTempDirectory().path,
OS.Path.basename(path) + ".tmp"
- )
+ ),
+ encoding: charset ? charset.toLowerCase() : 'utf-8'
}
));
}
- // Convert text data to stream
- if(!(data instanceof Components.interfaces.nsIInputStream)) {
- var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].
- createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
- converter.charset = charset ? Zotero.CharacterSets.getName(charset) : "UTF-8";
- data = converter.convertToInputStream(data);
- }
-
var deferred = Zotero.Promise.defer();
var os = FileUtils.openSafeFileOutputStream(new FileUtils.File(path));
NetUtil.asyncCopy(data, os, function(inputStream, status) {