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