Properly close files following detection
This commit is contained in:
parent
ebd7df3862
commit
a41841eb2b
2 changed files with 4 additions and 5 deletions
|
@ -143,9 +143,7 @@ Zotero.Translate.IO.Read = function(file, mode) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
|
||||||
// open file
|
// open file
|
||||||
this._rawStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
this._openRawStream();
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
|
||||||
this._rawStream.init(file, 0x01, 0664, 0);
|
|
||||||
|
|
||||||
// start detecting charset
|
// start detecting charset
|
||||||
var charset = null;
|
var charset = null;
|
||||||
|
@ -297,7 +295,7 @@ Zotero.Translate.IO.Read.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
"_seekToStart":function(charset) {
|
"_seekToStart":function(charset) {
|
||||||
this._rawStream.close();
|
if(this._rawStream) this._rawStream.close();
|
||||||
this._openRawStream();
|
this._openRawStream();
|
||||||
|
|
||||||
this._linesExhausted = false;
|
this._linesExhausted = false;
|
||||||
|
@ -398,6 +396,7 @@ Zotero.Translate.IO.Read.prototype = {
|
||||||
if(myIndex !== -1) Zotero.Translate.IO.maintainedInstances.splice(myIndex, 1);
|
if(myIndex !== -1) Zotero.Translate.IO.maintainedInstances.splice(myIndex, 1);
|
||||||
|
|
||||||
this._rawStream.close();
|
this._rawStream.close();
|
||||||
|
delete this._rawStream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Zotero.Translate.IO.Read.prototype.__defineGetter__("contentLength",
|
Zotero.Translate.IO.Read.prototype.__defineGetter__("contentLength",
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ Zotero.Translate.Import.prototype.setString = function(string) {
|
||||||
* Overload {@link Zotero.Translate.Base#complete} to close file
|
* Overload {@link Zotero.Translate.Base#complete} to close file
|
||||||
*/
|
*/
|
||||||
Zotero.Translate.Import.prototype.complete = function(returnValue, error) {
|
Zotero.Translate.Import.prototype.complete = function(returnValue, error) {
|
||||||
if(this._currentState == "translate" && this._io) {
|
if(this._io) {
|
||||||
this._progress = null;
|
this._progress = null;
|
||||||
this._io.close();
|
this._io.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue