* Add a notModified flag to Eepget and Eepget status listeners.
This commit is contained in:
@ -198,7 +198,7 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {
|
||||
// ignore
|
||||
}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("News fetched from " + url + " with " + (alreadyTransferred+bytesTransferred));
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class UpdateHandler {
|
||||
buf.append(" transferred<br />");
|
||||
_status = buf.toString();
|
||||
}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
_status = "<b>Update downloaded</b><br />";
|
||||
TrustedUpdate up = new TrustedUpdate(_context);
|
||||
boolean ok = up.migrateVerified(RouterVersion.VERSION, SIGNED_UPDATE_FILE, "i2pupdate.zip");
|
||||
|
@ -332,16 +332,18 @@ public class RemoteArchiveBean {
|
||||
}
|
||||
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
_statusMessages.add("Fetch of " + HTMLRenderer.sanitizeString(url) + " successful");
|
||||
_fetchIndexInProgress = false;
|
||||
ArchiveIndex i = new ArchiveIndex(I2PAppContext.getGlobalContext(), false);
|
||||
try {
|
||||
i.load(_archiveFile);
|
||||
_statusMessages.add("Archive fetched and loaded");
|
||||
_remoteIndex = i;
|
||||
} catch (IOException ioe) {
|
||||
_statusMessages.add("Archive is corrupt: " + ioe.getMessage());
|
||||
if (!notModified) {
|
||||
try {
|
||||
i.load(_archiveFile);
|
||||
_statusMessages.add("Archive fetched and loaded");
|
||||
_remoteIndex = i;
|
||||
} catch (IOException ioe) {
|
||||
_statusMessages.add("Archive is corrupt: " + ioe.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {
|
||||
@ -366,7 +368,7 @@ public class RemoteArchiveBean {
|
||||
}
|
||||
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
handleMetadata(url, outputFile);
|
||||
}
|
||||
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {
|
||||
@ -406,7 +408,7 @@ public class RemoteArchiveBean {
|
||||
}
|
||||
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
if (url.endsWith(".snm")) {
|
||||
handleMetadata(url, outputFile);
|
||||
return;
|
||||
@ -465,7 +467,7 @@ public class RemoteArchiveBean {
|
||||
}
|
||||
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
_statusMessages.add("Fetch of " + HTMLRenderer.sanitizeString(url.substring(0, url.indexOf('?'))) + " successful, importing the data");
|
||||
File file = new File(outputFile);
|
||||
ZipInputStream zi = null;
|
||||
|
@ -50,6 +50,7 @@ public class EepGet {
|
||||
private int _currentAttempt;
|
||||
private String _etag;
|
||||
private boolean _encodingChunked;
|
||||
private boolean _notModified;
|
||||
|
||||
public EepGet(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String outputFile, String url) {
|
||||
this(ctx, true, proxyHost, proxyPort, numRetries, outputFile, url);
|
||||
@ -173,7 +174,7 @@ public class EepGet {
|
||||
|
||||
public static interface StatusListener {
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url);
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile);
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified);
|
||||
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause);
|
||||
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt);
|
||||
public void headerReceived(String url, int currentAttempt, String key, String val);
|
||||
@ -236,12 +237,16 @@ public class EepGet {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
System.out.println();
|
||||
System.out.println("== " + new Date());
|
||||
System.out.println("== Transfer of " + url + " completed with " + (alreadyTransferred+bytesTransferred)
|
||||
+ " and " + (bytesRemaining - bytesTransferred) + " remaining");
|
||||
System.out.println("== Output saved to " + outputFile);
|
||||
if (notModified) {
|
||||
System.out.println("== Source not modified since last download");
|
||||
} else {
|
||||
System.out.println("== Transfer of " + url + " completed with " + (alreadyTransferred+bytesTransferred)
|
||||
+ " and " + (bytesRemaining - bytesTransferred) + " remaining");
|
||||
System.out.println("== Output saved to " + outputFile);
|
||||
}
|
||||
long timeToSend = _context.clock().now() - _startedOn;
|
||||
System.out.println("== Transfer time: " + DataHelper.formatDuration(timeToSend));
|
||||
System.out.println("== ETag: " + _etag);
|
||||
@ -359,7 +364,7 @@ public class EepGet {
|
||||
|
||||
if ( (_bytesRemaining == -1) || (remaining == 0) ){
|
||||
for (int i = 0; i < _listeners.size(); i++)
|
||||
((StatusListener)_listeners.get(i)).transferComplete(_alreadyTransferred, _bytesTransferred, _bytesRemaining, _url, _outputFile);
|
||||
((StatusListener)_listeners.get(i)).transferComplete(_alreadyTransferred, _bytesTransferred, _bytesRemaining, _url, _outputFile, _notModified);
|
||||
} else {
|
||||
throw new IOException("Disconnection on attempt " + _currentAttempt + " after " + _bytesTransferred);
|
||||
}
|
||||
@ -386,6 +391,7 @@ public class EepGet {
|
||||
case 304: // not modified
|
||||
_bytesRemaining = 0;
|
||||
_keepFetching = false;
|
||||
_notModified = true;
|
||||
return;
|
||||
case 416: // completed (or range out of reach)
|
||||
_bytesRemaining = 0;
|
||||
@ -613,4 +619,8 @@ public class EepGet {
|
||||
return _etag;
|
||||
}
|
||||
|
||||
public boolean getNotModified() {
|
||||
return _notModified;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ public class EepGetScheduler implements EepGet.StatusListener {
|
||||
_listener.bytesTransferred(alreadyTransferred, currentWrite, bytesTransferred, bytesRemaining, url);
|
||||
}
|
||||
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile) {
|
||||
_listener.transferComplete(alreadyTransferred, bytesTransferred, bytesRemaining, url, outputFile);
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
_listener.transferComplete(alreadyTransferred, bytesTransferred, bytesRemaining, url, outputFile, notModified);
|
||||
fetchNext();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
$Id: history.txt,v 1.274 2005/09/30 15:29:19 jrandom Exp $
|
||||
$Id: history.txt,v 1.275 2005/09/30 18:12:57 jrandom Exp $
|
||||
|
||||
2005-09-30 ragnarok
|
||||
* Implemented conditional get for syndie remote archive imports.
|
||||
|
||||
2005-09-30 jrandom
|
||||
* Killed three more streaming lib bugs, one of which caused excess packets
|
||||
|
Reference in New Issue
Block a user