return( null );
}
Torrent torrent = download.getTorrent();
if ( torrent.isPrivate()){
Debug.out( "Attempt to download private torrent" );
ddb.log( "TorrentDownload: request from " + originator + " for '" + download.getName() + "' denied as it is private" );
// should never happen as private torrents are not tracked so they can't be found for
// download
return( null );
}
String msg = "TorrentDownload: request from " + originator + " for '" + download.getName() + "' OK";
if ( TRACE ){
System.out.println( msg );
}
ddb.log( msg );
HashWrapper hw = new HashWrapper( torrent.getHash());
synchronized( data_cache ){
Object[] data = (Object[])data_cache.get( hw );
if ( data != null ){
data[1] = new Long( SystemTime.getCurrentTime());
return( ddb.createValue((byte[])data[0]));
}
}
torrent = torrent.removeAdditionalProperties();
// when clients get a torrent from the DHT they take on
// responsibility for tracking it too
torrent.setDecentralisedBackupRequested( true );
byte[] data = torrent.writeToBEncodedData();
data = encrypt( torrent.getHash(), data );
if ( data == null ){
return( null );
}