forked from I2P_Developers/i2p.i2p
Util: Fix NPE in EepGet CLI callback via PartialEepGet
Fix callback javadocs
This commit is contained in:
@ -429,9 +429,14 @@ public class EepGet {
|
|||||||
" (use -c or -p :0 for no proxy)");
|
" (use -c or -p :0 for no proxy)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback interface
|
||||||
|
*/
|
||||||
public static interface StatusListener {
|
public static interface StatusListener {
|
||||||
/**
|
/**
|
||||||
* alreadyTransferred - total of all attempts, not including currentWrite
|
* Total length should be == alreadyTransferred + currentWrite + bytesRemaining for all calls
|
||||||
|
*
|
||||||
|
* @param alreadyTransferred total of all attempts, not including currentWrite
|
||||||
* If nonzero on the first call, a partial file of that length was found,
|
* If nonzero on the first call, a partial file of that length was found,
|
||||||
* _and_ the server supports resume.
|
* _and_ the server supports resume.
|
||||||
* If zero on a subsequent call after some bytes are transferred
|
* If zero on a subsequent call after some bytes are transferred
|
||||||
@ -441,17 +446,25 @@ public class EepGet {
|
|||||||
* the listener should keep its own counter,
|
* the listener should keep its own counter,
|
||||||
* or subtract the initial alreadyTransferred value.
|
* or subtract the initial alreadyTransferred value.
|
||||||
* And watch out for alreadyTransferred resetting if a resume failed...
|
* And watch out for alreadyTransferred resetting if a resume failed...
|
||||||
* currentWrite - since last call to the listener
|
* @param currentWrite since last call to the listener
|
||||||
* bytesTransferred - includes headers, retries, redirects, discarded partial downloads, ...
|
* @param bytesTransferred includes headers, retries, redirects, discarded partial downloads, ...
|
||||||
* bytesRemaining - on this attempt only, currentWrite already subtracted -
|
* @param bytesRemaining on this attempt only, currentWrite already subtracted -
|
||||||
* or -1 if chunked encoding or server does not return a length
|
* or -1 if chunked encoding or server does not return a length
|
||||||
*
|
*
|
||||||
* Total length should be == alreadyTransferred + currentWrite + bytesRemaining for all calls
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url);
|
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url);
|
||||||
|
/**
|
||||||
|
* @see #bytesTransferred
|
||||||
|
* @param outputFile null if unknown (output stream constructor)
|
||||||
|
*/
|
||||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified);
|
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified);
|
||||||
|
/**
|
||||||
|
* @see #bytesTransferred
|
||||||
|
*/
|
||||||
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause);
|
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause);
|
||||||
|
/**
|
||||||
|
* @see #bytesTransferred
|
||||||
|
*/
|
||||||
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt);
|
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -555,7 +568,7 @@ public class EepGet {
|
|||||||
+ " bytes transferred" +
|
+ " bytes transferred" +
|
||||||
(_discarded > 0 ? (" and " + _discarded + " bytes discarded") : ""));
|
(_discarded > 0 ? (" and " + _discarded + " bytes discarded") : ""));
|
||||||
}
|
}
|
||||||
if (transferred > 0) {
|
if (transferred > 0 && outputFile != null) {
|
||||||
long sz = (new File(outputFile)).length();
|
long sz = (new File(outputFile)).length();
|
||||||
if (sz <= 0)
|
if (sz <= 0)
|
||||||
sz = alreadyTransferred;
|
sz = alreadyTransferred;
|
||||||
|
Reference in New Issue
Block a user