svnno****@sourc*****
svnno****@sourc*****
2008年 1月 27日 (日) 21:59:07 JST
Revision: 340 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=340 Author: flyson Date: 2008-01-27 21:59:07 +0900 (Sun, 27 Jan 2008) Log Message: ----------- 通信エラーでtempファイルが残ってしまうのを修正 Modified Paths: -------------- trunk/bbs2chreader/chrome/content/bbs2chreader/lib/downloader.js -------------- next part -------------- Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/lib/downloader.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/lib/downloader.js 2008-01-27 10:53:41 UTC (rev 339) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/lib/downloader.js 2008-01-27 12:59:07 UTC (rev 340) @@ -149,7 +149,7 @@ this._tempFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); this._tempFile.initWithPath(this._file.path + ".tmp"); this._tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); - if(!this._tempFile.exists()){ + if(!this._tempFile.clone().exists()){ this._tempFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); } }catch(ex){ @@ -161,6 +161,9 @@ try{ var fromURI = ioService.newURI(this.urlSpec, null, null); }catch(ex){ + if(this._tempFile.clone().exists()){ + this._tempFile.remove(false); + } this.onError(this, this.ERROR_BAD_URL); return; } @@ -175,6 +178,9 @@ this._httpChannel.asyncOpen(this._listener, this); this._loading = true; }catch(ex){ + if(this._tempFile.clone().exists()){ + this._tempFile.remove(false); + } this.onError(this, this.ERROR_FAILURE); return; } @@ -234,11 +240,17 @@ } context._tempFile.moveTo(context._file.parent, context._file.leafName); }catch(ex){ + if(context._tempFile.clone().exists()){ + context._tempFile.remove(false); + } context.onError(context, context.ERROR_BAD_FILE_PATH); } } context.onStop(context, httpStatus); }catch(ex){ + if(context._tempFile.clone().exists()){ + context._tempFile.remove(false); + } switch(aRequest.status){ case NS_ERROR_NET_TIMEOUT: context.onError(context, context.ERROR_NET_TIMEOUT); @@ -270,7 +282,7 @@ this._listener._outputStream.close(); this._listener._outputStream = null; } - if(this._tempFile.exists()){ + if(this._tempFile.clone().exists()){ this._tempFile.remove(false); } }catch(ex){}