- Move some torrent file creation code from the servlet to the manager,

to allow locking and prevent interference by the DirMonitor
- More checks for whether torrent is already running
- Consistent filename filtering in all cases
- Allow null announce string
- Move snarks map to a CHM
- Remember last tracker selection
- Add callback for reception of metainfo
This commit is contained in:
zzz
2010-12-21 16:36:08 +00:00
parent 8e40b35210
commit f15b329874
5 changed files with 255 additions and 52 deletions

View File

@ -64,6 +64,8 @@ public class MetaInfo
/**
* Called by Storage when creating a new torrent from local data
*
* @param announce may be null
*/
MetaInfo(String announce, String name, String name_utf8, List files, List lengths,
int piece_length, byte[] piece_hashes, long length)
@ -86,6 +88,7 @@ public class MetaInfo
* Creates a new MetaInfo from the given InputStream. The
* InputStream must start with a correctly bencoded dictonary
* describing the torrent.
* Caller must close the stream.
*/
public MetaInfo(InputStream in) throws IOException
{
@ -107,7 +110,9 @@ public class MetaInfo
* the original bencoded info dictonary (this is a hack, we could
* reconstruct the bencoded stream and recalculate the hash). Will
* NOT throw a InvalidBEncodingException if the given map does not
* contain a valid announce string or info dictonary.
* contain a valid announce string.
* WILL throw a InvalidBEncodingException if the given map does not
* contain a valid info dictionary.
*/
public MetaInfo(Map m) throws InvalidBEncodingException
{
@ -401,7 +406,8 @@ public class MetaInfo
public synchronized byte[] getTorrentData()
{
Map m = new HashMap();
m.put("announce", announce);
if (announce != null)
m.put("announce", announce);
Map info = createInfoMap();
m.put("info", info);
// don't save this locally, we should only do this once