commit a41841eb2b45a79504c627b18764a0708621a174
parent ebd7df386275ff77e02b31ee285123d61d842895
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 1 Mar 2011 21:41:13 +0000
Properly close files following detection
Diffstat:
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/browser_firefox.js b/chrome/content/zotero/xpcom/translation/browser_firefox.js
@@ -143,9 +143,7 @@ Zotero.Translate.IO.Read = function(file, mode) {
this.file = file;
// open file
- this._rawStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
- .createInstance(Components.interfaces.nsIFileInputStream);
- this._rawStream.init(file, 0x01, 0664, 0);
+ this._openRawStream();
// start detecting charset
var charset = null;
@@ -297,7 +295,7 @@ Zotero.Translate.IO.Read.prototype = {
},
"_seekToStart":function(charset) {
- this._rawStream.close();
+ if(this._rawStream) this._rawStream.close();
this._openRawStream();
this._linesExhausted = false;
@@ -398,6 +396,7 @@ Zotero.Translate.IO.Read.prototype = {
if(myIndex !== -1) Zotero.Translate.IO.maintainedInstances.splice(myIndex, 1);
this._rawStream.close();
+ delete this._rawStream;
}
}
Zotero.Translate.IO.Read.prototype.__defineGetter__("contentLength",
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js
@@ -1068,7 +1068,7 @@ Zotero.Translate.Import.prototype.setString = function(string) {
* Overload {@link Zotero.Translate.Base#complete} to close file
*/
Zotero.Translate.Import.prototype.complete = function(returnValue, error) {
- if(this._currentState == "translate" && this._io) {
+ if(this._io) {
this._progress = null;
this._io.close();
}