Properly close files following detection

This commit is contained in:
Simon Kornblith 2011-03-01 21:41:13 +00:00
parent ebd7df3862
commit a41841eb2b
2 changed files with 4 additions and 5 deletions

View File

@ -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",

View File

@ -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();
}