Changeset 6e4df88


Ignore:
Timestamp:
May 23, 2011 7:19:07 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
592361b
Parents:
7ab95d0
Message:
  • Force news refetch after URL change
Location:
apps/routerconsole/java/src/net/i2p/router/web
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java

    r7ab95d0 r6e4df88  
    11package net.i2p.router.web;
    22
    3 import net.i2p.I2PAppContext;
    43import net.i2p.crypto.TrustedUpdate;
    54import net.i2p.data.DataHelper;
     
    7978            return;
    8079        if (_action.equals(_("Check for updates"))) {
    81             NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext());
     80            NewsFetcher fetcher = NewsFetcher.getInstance(_context);
    8281            fetcher.fetchNews();
    8382            if (fetcher.shouldFetchUnsigned())
     
    101100            if ( (oldURL == null) || (!_newsURL.equals(oldURL)) ) {
    102101                _context.router().setConfigSetting(PROP_NEWS_URL, _newsURL);
     102                NewsFetcher.getInstance(_context).invalidateNews();
    103103                addFormNotice(_("Updating news URL to") + " " + _newsURL);
    104104            }
  • apps/routerconsole/java/src/net/i2p/router/web/NewsFetcher.java

    r7ab95d0 r6e4df88  
    3434    private String _unsignedUpdateVersion;
    3535    private String _lastModified;
     36    private boolean _invalidated;
    3637    private File _newsFile;
    3738    private File _tempFile;
     
    135136   
    136137    private boolean shouldFetchNews() {
     138        if (_invalidated)
     139            return true;
    137140        updateLastFetched();
    138141        String freq = _context.getProperty(ConfigUpdateHandler.PROP_REFRESH_FREQUENCY,
     
    156159        }
    157160    }
     161
     162    /**
     163     *  Call this when changing news URLs to force an update next time the timer fires.
     164     *  @since 0.8.7
     165     */
     166    void invalidateNews() {
     167        _lastModified = null;
     168        _invalidated = true;
     169    }
     170
    158171    public void fetchNews() {
    159172        String newsURL = ConfigUpdateHelper.getNewsURL(_context);
     
    173186            if (get.fetch()) {
    174187                _lastModified = get.getLastModified();
     188                _invalidated = false;
    175189            } else {
    176190                // backup news location - always proxied
Note: See TracChangeset for help on using the changeset viewer.