* NewsFetcher: Fix bug causing fetch every 10m

This commit is contained in:
zzz
2008-03-22 17:10:49 +00:00
parent 9500a55532
commit 42bbb4a9ff
3 changed files with 11 additions and 7 deletions

View File

@ -41,14 +41,16 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
_context = ctx; _context = ctx;
_log = ctx.logManager().getLog(NewsFetcher.class); _log = ctx.logManager().getLog(NewsFetcher.class);
_instance = this; _instance = this;
_lastFetch = 0;
updateLastFetched(); updateLastFetched();
} }
private void updateLastFetched() { private void updateLastFetched() {
File news = new File(NEWS_FILE); File news = new File(NEWS_FILE);
if (news.exists()) if (news.exists()) {
if (_lastFetch == 0)
_lastFetch = news.lastModified(); _lastFetch = news.lastModified();
else } else
_lastFetch = 0; _lastFetch = 0;
} }
@ -115,8 +117,6 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
} catch (Throwable t) { } catch (Throwable t) {
_log.error("Error fetching the news", t); _log.error("Error fetching the news", t);
} }
_lastFetch = _context.clock().now();
} }
private static final String VERSION_STRING = "version=\"" + RouterVersion.VERSION + "\""; private static final String VERSION_STRING = "version=\"" + RouterVersion.VERSION + "\"";
@ -209,6 +209,7 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
boolean copied = FileUtil.copy(TEMP_NEWS_FILE, NEWS_FILE, true); boolean copied = FileUtil.copy(TEMP_NEWS_FILE, NEWS_FILE, true);
if (copied) { if (copied) {
temp.delete(); temp.delete();
checkForUpdates();
} else { } else {
if (_log.shouldLog(Log.ERROR)) if (_log.shouldLog(Log.ERROR))
_log.error("Failed to copy the news file!"); _log.error("Failed to copy the news file!");
@ -217,7 +218,7 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Transfer complete, but no file? - probably 304 Not Modified"); _log.warn("Transfer complete, but no file? - probably 304 Not Modified");
} }
checkForUpdates(); _lastFetch = _context.clock().now();
} }
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) { public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {

View File

@ -1,3 +1,6 @@
2008-03-22 zzz
* NewsFetcher: Fix bug causing fetch every 10m
2008-03-22 zzz 2008-03-22 zzz
* Tunnel Testing: * Tunnel Testing:
- Fix counting so it really takes 4 consecutive failures - Fix counting so it really takes 4 consecutive failures

View File

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