From a41841eb2b45a79504c627b18764a0708621a174 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 1 Mar 2011 21:41:13 +0000 Subject: [PATCH] Properly close files following detection --- chrome/content/zotero/xpcom/translation/browser_firefox.js | 7 +++---- chrome/content/zotero/xpcom/translation/translate.js | 2 +- 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 index 863f28184..21aef4e0a 100644 --- 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 index eaf0e3521..52a513b37 100644 --- 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(); }