* EepGet command line: Fix byte counts after a failed resume

* UpdateHandler: Cleanup, clarify failure message
This commit is contained in:
zzz
2008-09-06 13:52:46 +00:00
parent 1091a289d2
commit 9a2792e64c
4 changed files with 36 additions and 11 deletions

View File

@ -121,7 +121,6 @@ public class UpdateHandler {
try {
proxyPort = Integer.parseInt(port);
} catch (NumberFormatException nfe) {
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
return;
}
try {
@ -135,7 +134,6 @@ public class UpdateHandler {
get.fetch();
} catch (Throwable t) {
_context.logManager().getLog(UpdateHandler.class).error("Error updating", t);
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
}
}
@ -176,15 +174,14 @@ public class UpdateHandler {
err = err + " from " + url;
_log.log(Log.CRIT, err);
_status = "<b>" + err + "</b>";
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
}
}
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {
_log.log(Log.CRIT, "Update from " + url + " did not download completely (" + bytesTransferred + " with "
+ bytesRemaining + " after " + currentAttempt + " tries)");
// don't display bytesTransferred as it is meaningless
_log.log(Log.CRIT, "Update from " + url + " did not download completely (" +
bytesRemaining + " remaining after " + currentAttempt + " tries)");
_status = "<b>Transfer failed</b>";
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
}
public void headerReceived(String url, int attemptNum, String key, String val) {}
public void attempting(String url) {}

View File

@ -214,12 +214,17 @@ public class EepGet {
public static interface StatusListener {
/**
* 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.
* If zero on a subsequent call after some bytes are transferred
* (and presumably after an attemptFailed), the server does _not_
* support resume and we had to start over.
* To track _actual_ transfer if the output file could already exist,
* the listener should keep its own counter,
* or subtract the initial alreadyTransferred value.
* And watch out for alreadyTransferred resetting if a resume failed...
* currentWrite - since last call to the listener
* bytesTransferred - includes headers, retries, redirects, ...
* bytesTransferred - includes headers, retries, redirects, discarded partial downloads, ...
* bytesRemaining - on this attempt only, currentWrite already subtracted -
* or -1 if chunked encoding or server does not return a length
*
@ -239,6 +244,7 @@ public class EepGet {
private long _startedOn;
private long _written;
private long _previousWritten;
private long _discarded;
private long _lastComplete;
private boolean _firstTime;
private DecimalFormat _pct = new DecimalFormat("00.0%");
@ -251,6 +257,7 @@ public class EepGet {
_lineSize = lineSize;
_written = 0;
_previousWritten = 0;
_discarded = 0;
_lastComplete = _context.clock().now();
_startedOn = _lastComplete;
_firstTime = true;
@ -263,6 +270,12 @@ public class EepGet {
}
_firstTime = false;
}
if (_written == 0 && alreadyTransferred == 0 && _previousWritten > 0) {
// boo
System.out.println("Server does not support resume, discarding " + _previousWritten + " bytes");
_discarded += _previousWritten;
_previousWritten = 0;
}
for (int i = 0; i < currentWrite; i++) {
_written++;
if ( (_markSize > 0) && (_written % _markSize == 0) ) {
@ -318,10 +331,12 @@ public class EepGet {
} else {
if ( bytesRemaining > 0 ) {
System.out.println("== Transfer of " + url + " completed with " + transferred
+ " transferred and " + (bytesRemaining - bytesTransferred) + " remaining");
+ " transferred and " + (bytesRemaining - bytesTransferred) + " remaining" +
(_discarded > 0 ? (" and " + _discarded + " bytes discarded") : ""));
} else {
System.out.println("== Transfer of " + url + " completed with " + transferred
+ " bytes transferred");
+ " bytes transferred" +
(_discarded > 0 ? (" and " + _discarded + " bytes discarded") : ""));
}
if (transferred > 0)
System.out.println("== Output saved to " + outputFile + " (" + alreadyTransferred + " bytes)");
@ -616,6 +631,8 @@ public class EepGet {
if (_log.shouldLog(Log.DEBUG))
_log.debug("rc: " + responseCode + " for " + _actualURL);
if(_transferFailed)
_log.error("Already failed for " + _actualURL);
boolean rcOk = false;
switch (responseCode) {
case 200: // full

View File

@ -1,3 +1,14 @@
2008-09-06 zzz
* EepGet command line: Fix byte counts after a failed resume
* NTCP: Mark unreachable on outbound connection timeout
* Shitlist: Fix partial shitlisting (still unused though)
* Summary Bar: Warn if firewalled and floodfill
* Throttle: Combine current and last bw measurement,
reduce default max tunnels to 2500 (was 3000)
* Tunnel BuildHandler: Logging cleanup
* UpdateHandler: Cleanup, clarify failure message
* DataHelper: Prepare for 999 day uptime :)
2008-08-29 zzz
* Tunnel BuildExecutor: Debug cleanup
* Profiles: Penalize capacity when tunnel build request times out

View File

@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
public class RouterVersion {
public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
public final static String VERSION = "0.6.3";
public final static long BUILD = 2;
public final static long BUILD = 3;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);