forked from I2P_Developers/i2p.i2p
i2psnark: Add support for comment and url_list to Storage CLI
Add support for multiple urls to MetaInfo CLI Add comment to release torrent
This commit is contained in:
@ -792,7 +792,7 @@ public class MetaInfo
|
|||||||
boolean error = false;
|
boolean error = false;
|
||||||
String created_by = null;
|
String created_by = null;
|
||||||
String announce = null;
|
String announce = null;
|
||||||
String url = null;
|
List<String> url_list = null;
|
||||||
String comment = null;
|
String comment = null;
|
||||||
Getopt g = new Getopt("Storage", args, "a:c:m:w:");
|
Getopt g = new Getopt("Storage", args, "a:c:m:w:");
|
||||||
try {
|
try {
|
||||||
@ -812,7 +812,9 @@ public class MetaInfo
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
url = g.getOptarg();
|
if (url_list == null)
|
||||||
|
url_list = new ArrayList<String>();
|
||||||
|
url_list.add(g.getOptarg());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
@ -827,7 +829,7 @@ public class MetaInfo
|
|||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
if (error || args.length - g.getOptind() <= 0) {
|
if (error || args.length - g.getOptind() <= 0) {
|
||||||
System.err.println("Usage: MetaInfo [-a announceURL] [-c created-by] [-m comment] [-w web-seed-url] file.torrent [file2.torrent...]");
|
System.err.println("Usage: MetaInfo [-a announceURL] [-c created-by] [-m comment] [-w webseed-url]* file.torrent [file2.torrent...]");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
for (int i = g.getOptind(); i < args.length; i++) {
|
for (int i = g.getOptind(); i < args.length; i++) {
|
||||||
@ -842,11 +844,11 @@ public class MetaInfo
|
|||||||
"\nWebSeed URLs: " + meta.getWebSeedURLs() +
|
"\nWebSeed URLs: " + meta.getWebSeedURLs() +
|
||||||
"\nCreated By: " + meta.getCreatedBy() +
|
"\nCreated By: " + meta.getCreatedBy() +
|
||||||
"\nComment: " + meta.getComment());
|
"\nComment: " + meta.getComment());
|
||||||
if (created_by != null || announce != null || url != null || comment != null) {
|
if (created_by != null || announce != null || url_list != null || comment != null) {
|
||||||
String cb = created_by != null ? created_by : meta.getCreatedBy();
|
String cb = created_by != null ? created_by : meta.getCreatedBy();
|
||||||
String an = announce != null ? announce : meta.getAnnounce();
|
String an = announce != null ? announce : meta.getAnnounce();
|
||||||
String cm = comment != null ? comment : meta.getComment();
|
String cm = comment != null ? comment : meta.getComment();
|
||||||
List<String> urls = url != null ? Collections.singletonList(url) : meta.getWebSeedURLs();
|
List<String> urls = url_list != null ? url_list : meta.getWebSeedURLs();
|
||||||
// changes/adds creation date
|
// changes/adds creation date
|
||||||
MetaInfo meta2 = new MetaInfo(an, meta.getName(), null, meta.getFiles(), meta.getLengths(),
|
MetaInfo meta2 = new MetaInfo(an, meta.getName(), null, meta.getFiles(), meta.getLengths(),
|
||||||
meta.getPieceLength(0), meta.getPieceHashes(), meta.getTotalLength(), meta.isPrivate(),
|
meta.getPieceLength(0), meta.getPieceHashes(), meta.getTotalLength(), meta.isPrivate(),
|
||||||
|
@ -144,6 +144,30 @@ public class Storage implements Closeable
|
|||||||
String created_by,
|
String created_by,
|
||||||
boolean privateTorrent, StorageListener listener)
|
boolean privateTorrent, StorageListener listener)
|
||||||
throws IOException
|
throws IOException
|
||||||
|
{
|
||||||
|
this(util, baseFile, announce, announce_list, created_by, privateTorrent, null, null, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a storage from the existing file or directory.
|
||||||
|
* Creates an in-memory metainfo but does not save it to
|
||||||
|
* a file, caller must do that.
|
||||||
|
*
|
||||||
|
* Creates the metainfo, this may take a LONG time. BLOCKING.
|
||||||
|
*
|
||||||
|
* @param announce may be null
|
||||||
|
* @param listener may be null
|
||||||
|
* @param created_by may be null
|
||||||
|
* @param url_list may be null
|
||||||
|
* @param comment may be null
|
||||||
|
* @throws IOException when creating and/or checking files fails.
|
||||||
|
* @since 0.9.48
|
||||||
|
*/
|
||||||
|
public Storage(I2PSnarkUtil util, File baseFile, String announce,
|
||||||
|
List<List<String>> announce_list,
|
||||||
|
String created_by,
|
||||||
|
boolean privateTorrent, List<String> url_list, String comment, StorageListener listener)
|
||||||
|
throws IOException
|
||||||
{
|
{
|
||||||
_util = util;
|
_util = util;
|
||||||
_base = baseFile;
|
_base = baseFile;
|
||||||
@ -210,7 +234,7 @@ public class Storage implements Closeable
|
|||||||
byte[] piece_hashes = fast_digestCreate();
|
byte[] piece_hashes = fast_digestCreate();
|
||||||
metainfo = new MetaInfo(announce, baseFile.getName(), null, files,
|
metainfo = new MetaInfo(announce, baseFile.getName(), null, files,
|
||||||
lengthsList, piece_size, piece_hashes, total, privateTorrent,
|
lengthsList, piece_size, piece_hashes, total, privateTorrent,
|
||||||
announce_list, created_by, null, null);
|
announce_list, created_by, url_list, comment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1685,7 +1709,9 @@ public class Storage implements Closeable
|
|||||||
boolean error = false;
|
boolean error = false;
|
||||||
String created_by = null;
|
String created_by = null;
|
||||||
String announce = null;
|
String announce = null;
|
||||||
Getopt g = new Getopt("Storage", args, "a:c:");
|
List<String> url_list = null;
|
||||||
|
String comment = null;
|
||||||
|
Getopt g = new Getopt("Storage", args, "a:c:m:w:");
|
||||||
try {
|
try {
|
||||||
int c;
|
int c;
|
||||||
while ((c = g.getopt()) != -1) {
|
while ((c = g.getopt()) != -1) {
|
||||||
@ -1698,6 +1724,16 @@ public class Storage implements Closeable
|
|||||||
created_by = g.getOptarg();
|
created_by = g.getOptarg();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'm':
|
||||||
|
comment = g.getOptarg();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
if (url_list == null)
|
||||||
|
url_list = new ArrayList<String>();
|
||||||
|
url_list.add(g.getOptarg());
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
case ':':
|
case ':':
|
||||||
default:
|
default:
|
||||||
@ -1710,7 +1746,7 @@ public class Storage implements Closeable
|
|||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
if (error || args.length - g.getOptind() != 1) {
|
if (error || args.length - g.getOptind() != 1) {
|
||||||
System.err.println("Usage: Storage [-a announceURL] [-c created-by] file-or-dir");
|
System.err.println("Usage: Storage [-a announceURL] [-c created-by] [-m comment] [-w webseed-url]* file-or-dir");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
File base = new File(args[g.getOptind()]);
|
File base = new File(args[g.getOptind()]);
|
||||||
@ -1719,7 +1755,7 @@ public class Storage implements Closeable
|
|||||||
File file = null;
|
File file = null;
|
||||||
FileOutputStream out = null;
|
FileOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
Storage storage = new Storage(util, base, announce, null, created_by, false, null);
|
Storage storage = new Storage(util, base, announce, null, created_by, false, url_list, comment, null);
|
||||||
MetaInfo meta = storage.getMetaInfo();
|
MetaInfo meta = storage.getMetaInfo();
|
||||||
file = new File(storage.getBaseName() + ".torrent");
|
file = new File(storage.getBaseName() + ".torrent");
|
||||||
out = new FileOutputStream(file);
|
out = new FileOutputStream(file);
|
||||||
|
@ -141,6 +141,8 @@
|
|||||||
<arg value="http://tracker2.postman.i2p/announce.php" />
|
<arg value="http://tracker2.postman.i2p/announce.php" />
|
||||||
<arg value="-c" />
|
<arg value="-c" />
|
||||||
<arg value="${build.built-by}" />
|
<arg value="${build.built-by}" />
|
||||||
|
<arg value="-m" />
|
||||||
|
<arg value="Official torrent for version ${full.version}" />
|
||||||
<arg value="@{file}" />
|
<arg value="@{file}" />
|
||||||
</java>
|
</java>
|
||||||
</sequential>
|
</sequential>
|
||||||
@ -1686,6 +1688,12 @@
|
|||||||
<target name="signed-updater200WithJavadoc" depends="-pre-sign, updater200WithJavadoc, -sign-update" />
|
<target name="signed-updater200WithJavadoc" depends="-pre-sign, updater200WithJavadoc, -sign-update" />
|
||||||
<target name="signed-updater200WithJavadocAndJetty" depends="-pre-sign, updater200WithJavadocAndJetty, -sign-update" />
|
<target name="signed-updater200WithJavadocAndJetty" depends="-pre-sign, updater200WithJavadocAndJetty, -sign-update" />
|
||||||
|
|
||||||
|
<!-- just to test the torrent creation macro -->
|
||||||
|
<target name="updater-torrent" depends="updater">
|
||||||
|
<copy file="i2pupdate.zip" tofile="i2pupdate-${full.version}.zip" />
|
||||||
|
<mktorrent file="i2pupdate-${full.version}.zip" />
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="zipit" depends="getReleaseNumber">
|
<target name="zipit" depends="getReleaseNumber">
|
||||||
<!--
|
<!--
|
||||||
As of release 0.8.8, the router will enforce a zipfile comment equal to the
|
As of release 0.8.8, the router will enforce a zipfile comment equal to the
|
||||||
|
Reference in New Issue
Block a user