Update of /cvsroot/azureus/azureus2/org/gudy/azureus2/core3/torrentdownloader/impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26656/org/gudy/azureus2/core3/torrentdownloader/impl
Modified Files:
TorrentDownloaderImpl.java
Log Message:
fix for retry not enabled after magnet download fail + subsequent temp files not being deleted
Index: TorrentDownloaderImpl.java
===================================================================
RCS file: /cvsroot/azureus/azureus2/org/gudy/azureus2/core3/torrentdownloader/impl/TorrentDownloaderImpl.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- TorrentDownloaderImpl.java 20 May 2005 13:35:30 -0000 1.34
+++ TorrentDownloaderImpl.java 29 Jun 2005 20:55:45 -0000 1.35
@@ -290,24 +290,23 @@
} catch( Throwable e ){
this.error("Exception while initializing download of '" + url + "':" + e.toString());
}
- if (this.state != STATE_ERROR) {
- this.state = STATE_START;
-
- notifyListener();
+
+ if ( this.state == STATE_ERROR ){
+
+ return;
+ }
+
+ try{
+ final boolean status_reader_run[] = { true };
+
+ this.state = STATE_START;
- this.state = STATE_DOWNLOADING;
+ notifyListener();
- notifyListener();
+ this.state = STATE_DOWNLOADING;
- try {
- this.file = new File(this.directoryname, this.filename);
-
- this.file.createNewFile();
-
- FileOutputStream fileout = new FileOutputStream(this.file, false);
-
- final boolean status_reader_run[] = { true };
-
+ notifyListener();
+
Thread status_reader =
new AEThread( "TorrentDownloader:statusreader" )
{
@@ -337,7 +336,14 @@
if ( !s.equals( getStatus())){
- setStatus(s);
+ if ( s.toLowerCase().indexOf( "no sources found" ) == -1 ){
+
+ setStatus(s);
+
+ }else{
+
+ error(s);
+ }
changed_status = true;
}
@@ -357,87 +363,114 @@
status_reader.setDaemon( true );
status_reader.start();
-
+
InputStream in;
-
+
try{
in = this.con.getInputStream();
-
+
}finally{
try{
this_mon.enter();
-
+
status_reader_run[0] = false;
}finally{
-
+
this_mon.exit();
}
}
-
- byte[] buf = new byte[1020];
- int read = 0;
- int size = this.con.getContentLength();
- this.percentDone = -1;
- do {
- if (this.cancel)
- break;
- try {
- read = in.read(buf);
- this.readTotal += read;
- if (size != 0)
- this.percentDone = (100 * this.readTotal) / size;
- notifyListener();
- } catch (IOException e) {
- }
- if (read > 0)
- fileout.write(buf, 0, read);
- } while (read > 0);
- in.close();
- fileout.flush();
- fileout.close();
- if (this.cancel) {
- this.state = STATE_CANCELLED;
- this.cleanUpFile();
- } else {
- if (this.readTotal <= 0) {
- this.error("No data contained in '" + this.url.toString() + "'");
- return;
- }
-
- // if the file has come down with a not-so-useful name then we try to rename
- // it to something more useful
-
- try{
- if ( !filename.toLowerCase().endsWith(".torrent" )){
-
- TOTorrent torrent = TorrentUtils.readFromFile( file, false );
-
- String name = TorrentUtils.getLocalisedName( torrent ) + ".torrent";
-
- File new_file = new File( directoryname, name );
-
- if ( file.renameTo( new_file )){
-
- filename = name;
-
- file = new_file;
- }
- }
- }catch( Throwable e ){
-
- Debug.printStackTrace( e );
- }
-
- this.state = STATE_FINISHED;
- }
- this.notifyListener();
+
+ if ( this.state != STATE_ERROR ){
+
+ this.file = new File(this.directoryname, this.filename);
+
+ this.file.createNewFile();
+
+ FileOutputStream fileout = new FileOutputStream(this.file, false);
+
+ byte[] buf = new byte[1020];
+
+ int read = 0;
+
+ int size = this.con.getContentLength();
+
+ this.percentDone = -1;
+
+ do {
+ if (this.cancel){
+ break;
+ }
+
+ try {
+ read = in.read(buf);
+
+ this.readTotal += read;
+
+ if (size != 0){
+ this.percentDone = (100 * this.readTotal) / size;
+ }
+
+ notifyListener();
+
+ } catch (IOException e) {
+ }
+
+ if (read > 0){
+ fileout.write(buf, 0, read);
+ }
+ } while (read > 0);
+
+ in.close();
+
+ fileout.flush();
+
+ fileout.close();
+
+ if (this.cancel) {
+ this.state = STATE_CANCELLED;
+ this.cleanUpFile();
+ } else {
+ if (this.readTotal <= 0) {
+ this.error("No data contained in '" + this.url.toString() + "'");
+ return;
+ }
+
+ // if the file has come down with a not-so-useful name then we try to rename
+ // it to something more useful
+
+ try{
+ if ( !filename.toLowerCase().endsWith(".torrent" )){
+
+ TOTorrent torrent = TorrentUtils.readFromFile( file, false );
+
+ String name = TorrentUtils.getLocalisedName( torrent ) + ".torrent";
+
+ File new_file = new File( directoryname, name );
+
+ if ( file.renameTo( new_file )){
+
+ filename = name;
+
+ file = new_file;
+ }
+ }
+ }catch( Throwable e ){
+
+ Debug.printStackTrace( e );
+ }
+
+ this.state = STATE_FINISHED;
+ }
+ this.notifyListener();
+ }
} catch (Exception e) {
+
Debug.printStackTrace( e );
+
this.error("Exception while downloading '" + this.url.toString() + "':" + e.getMessage());
}
- }
}
public boolean equals(Object obj) {
|