i2psnark: Revert API changes that broke i2psnark-rpc plugin

compile-tested only
This commit is contained in:
zzz
2020-02-17 15:47:03 +00:00
parent fd958df118
commit daf595ab7e
3 changed files with 29 additions and 4 deletions

View File

@ -489,6 +489,21 @@ public class Snark
_comments = completeListener.getSavedComments(this); _comments = completeListener.getSavedComments(this);
} }
/**
* multitorrent, magnet, Used by snark-rpc plugin
*
* Will not start itself. Caller must call startTorrent() if desired.
*
* @param ignored used to be autostart
* @throws RuntimeException via fatal()
* @since 0.8.4, removed in 0.9.36, restored in 0.9.45 with boolean param now ignored
*/
protected Snark(I2PSnarkUtil util, String torrent, byte[] ih, String trackerURL,
CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor, boolean ignored, String rootDir) {
this(util, torrent, ih, trackerURL, complistener, peerCoordinatorSet, connectionAcceptor, rootDir);
}
/** /**
* multitorrent, magnet * multitorrent, magnet
* *

View File

@ -426,14 +426,24 @@ public class Storage implements Closeable
} }
****/ ****/
/**
* For efficiency, calculate remaining bytes for all files at once
*
* @return number of bytes remaining for each file, use indexOf() to get index for a file
* @since 0.9.23
*/
public long[] remaining() {
return remaining2()[0];
}
/** /**
* For efficiency, calculate remaining bytes for all files at once. * For efficiency, calculate remaining bytes for all files at once.
* Remaining bytes is rv[0]. Preview bytes is rv[1]. * Remaining bytes is rv[0]. Preview bytes is rv[1].
* *
* @return number of bytes remaining and number of bytes available for a preview for each file, use indexOf() to get index for a file * @return number of bytes remaining and number of bytes available for a preview for each file, use indexOf() to get index for a file
* @since 0.9.23 * @since 0.9.45
*/ */
public long[][] remaining() { public long[][] remaining2() {
long[] rv = new long[_torrentFiles.size()]; long[] rv = new long[_torrentFiles.size()];
long[] pv = new long[_torrentFiles.size()]; long[] pv = new long[_torrentFiles.size()];
long[][] rva = new long[][] { rv, pv }; long[][] rva = new long[][] { rv, pv };

View File

@ -3375,7 +3375,7 @@ public class I2PSnarkServlet extends BasicServlet {
List<Sorters.FileAndIndex> fileList = new ArrayList<Sorters.FileAndIndex>(ls.length); List<Sorters.FileAndIndex> fileList = new ArrayList<Sorters.FileAndIndex>(ls.length);
// precompute remaining for all files for efficiency // precompute remaining for all files for efficiency
long[][] arrays = (storage != null) ? storage.remaining() : null; long[][] arrays = (storage != null) ? storage.remaining2() : null;
long[] remainingArray = (arrays != null) ? arrays[0] : null; long[] remainingArray = (arrays != null) ? arrays[0] : null;
long[] previewArray = (arrays != null) ? arrays[1] : null; long[] previewArray = (arrays != null) ? arrays[1] : null;
for (int i = 0; i < ls.length; i++) { for (int i = 0; i < ls.length; i++) {
@ -3764,7 +3764,7 @@ public class I2PSnarkServlet extends BasicServlet {
return null; return null;
List<Sorters.FileAndIndex> fileList = new ArrayList<Sorters.FileAndIndex>(ls.length); List<Sorters.FileAndIndex> fileList = new ArrayList<Sorters.FileAndIndex>(ls.length);
// precompute remaining for all files for efficiency // precompute remaining for all files for efficiency
long[] remainingArray = (storage != null) ? storage.remaining()[0] : null; long[] remainingArray = (storage != null) ? storage.remaining() : null;
for (int i = 0; i < ls.length; i++) { for (int i = 0; i < ls.length; i++) {
fileList.add(new Sorters.FileAndIndex(ls[i], storage, remainingArray)); fileList.add(new Sorters.FileAndIndex(ls[i], storage, remainingArray));
} }