informActivity( getLogIndent() + ( file.isDirectory()?"Processing: ":"Downloading: " ) + getName());
final Object parent_tls = TorrentUtils.getTLS();
AEThread2 t =
new AEThread2( "ResourceDownloaderTimeout", true )
{
public void
run()
{
Object child_tls = TorrentUtils.getTLS();
TorrentUtils.setTLS( parent_tls );
try{
// download of a local dir -> null inputstream
if ( file.isDirectory()){
completed( ResourceDownloaderFileImpl.this, null );
}else{
completed( ResourceDownloaderFileImpl.this, new FileInputStream( file ));
}
}catch( Throwable e ){
failed( ResourceDownloaderFileImpl.this, new ResourceDownloaderException( ResourceDownloaderFileImpl.this, "Failed to read file", e ));
Debug.printStackTrace( e );
}finally{
TorrentUtils.setTLS( child_tls );
}
}
};
t.start();
}
}finally{
this_mon.exit();
}