forked from I2P_Developers/i2p.i2p
i2psnark: Enable sequential order option for single-file torrents (ticket #2234)
This commit is contained in:
@ -440,9 +440,9 @@ public class Storage implements Closeable
|
||||
*/
|
||||
public int getPriority(int fileIndex) {
|
||||
if (complete() || metainfo.getFiles() == null)
|
||||
return 0;
|
||||
return PRIORITY_NORMAL;
|
||||
if (fileIndex < 0 || fileIndex >= _torrentFiles.size())
|
||||
return 0;
|
||||
return PRIORITY_NORMAL;
|
||||
return _torrentFiles.get(fileIndex).priority;
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ public class Storage implements Closeable
|
||||
void setFilePriorities(int[] p) {
|
||||
if (p == null) {
|
||||
for (TorrentFile tf : _torrentFiles) {
|
||||
tf.priority = 0;
|
||||
tf.priority = PRIORITY_NORMAL;
|
||||
}
|
||||
} else {
|
||||
int sz = _torrentFiles.size();
|
||||
@ -517,7 +517,7 @@ public class Storage implements Closeable
|
||||
if (yes == _inOrder)
|
||||
return;
|
||||
_inOrder = yes;
|
||||
if (complete() || metainfo.getFiles() == null)
|
||||
if (complete())
|
||||
return;
|
||||
if (yes) {
|
||||
List<TorrentFile> sorted = _torrentFiles;
|
||||
@ -560,11 +560,11 @@ public class Storage implements Closeable
|
||||
* Set the piece priority to the highest priority
|
||||
* of all files spanning the piece.
|
||||
* Caller must pass array to the PeerCoordinator.
|
||||
* @return null on error, if complete, or if only one file
|
||||
* @return null on error, if complete, or if only one file and inOrder not set.
|
||||
* @since 0.8.1
|
||||
*/
|
||||
public int[] getPiecePriorities() {
|
||||
if (complete() || metainfo.getFiles() == null)
|
||||
if (complete() || (metainfo.getFiles() == null && !_inOrder))
|
||||
return null;
|
||||
int[] rv = new int[metainfo.getPieces()];
|
||||
int file = 0;
|
||||
|
@ -3286,11 +3286,14 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
.append("\">\n");
|
||||
}
|
||||
boolean showInOrder = storage != null && !storage.complete() &&
|
||||
meta != null && meta.getFiles() != null && meta.getFiles().size() > 1;
|
||||
meta != null;
|
||||
if (showInOrder) {
|
||||
buf.append("</td></tr>\n" +
|
||||
"<tr id=\"torrentOrderControl\"><td colspan=\"2\">");
|
||||
buf.append(_t("Download files in order"));
|
||||
String txt = (meta.getFiles() != null && meta.getFiles().size() > 1) ?
|
||||
_t("Download files in order") :
|
||||
_t("Download pieces in order");
|
||||
buf.append(txt);
|
||||
buf.append(":<input type=\"checkbox\" class=\"optbox\" name=\"enableInOrder\" id=\"enableInOrder\" ");
|
||||
if (storage.getInOrder())
|
||||
buf.append("checked=\"checked\"");
|
||||
|
Reference in New Issue
Block a user