Proritize currently requested site update

This commit is contained in:
shortcutme 2018-06-03 12:46:00 +02:00
parent 250741e431
commit d125551c0d
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
2 changed files with 7 additions and 1 deletions

View File

@ -41,7 +41,6 @@ class Site(object):
self.peers = {} # Key: ip:port, Value: Peer.Peer
self.peers_recent = collections.deque(maxlen=100)
self.peer_blacklist = SiteManager.peer_blacklist # Ignore this peers (eg. myself)
self.time_announce = 0 # Last announce time to tracker
self.worker_manager = WorkerManager(self) # Handle site download from other peers
self.bad_files = {} # SHA check failed files, need to redownload {"inner.content": 1} (key: file, value: failed accept)
self.content_updated = None # Content.js update time

View File

@ -5,6 +5,8 @@ import mimetypes
import json
import cgi
import gevent
from Config import config
from Site import SiteManager
from User import UserManager
@ -307,6 +309,11 @@ class UiRequest(object):
return False
self.sendHeader(extra_headers=extra_headers)
if time.time() - site.announcer.time_last_announce > 60 * 60:
site.log.debug("Site requested, but not announced recently. Updating...")
gevent.spawn(site.update, announce=True)
return iter([self.renderWrapper(site, path, inner_path, title, extra_headers)])
# Make response be sent at once (see https://github.com/HelloZeroNet/ZeroNet/issues/1092)