Support since parameter for siteUpdate

This commit is contained in:
shortcutme 2017-01-29 19:02:08 +01:00
parent 1668659ff6
commit 2b389e4e85
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 6 additions and 5 deletions

View file

@ -314,6 +314,7 @@ class Site(object):
# Check modified content.json files from peers and add modified files to bad_files # Check modified content.json files from peers and add modified files to bad_files
# Return: Successfully queried peers [Peer, Peer...] # Return: Successfully queried peers [Peer, Peer...]
def checkModifications(self, since=None): def checkModifications(self, since=None):
s = time.time()
peers_try = [] # Try these peers peers_try = [] # Try these peers
queried = [] # Successfully queried from these peers queried = [] # Successfully queried from these peers
@ -344,14 +345,14 @@ class Site(object):
if not queried: if not queried:
gevent.joinall(updaters, timeout=10) # Wait another 10 sec if none of updaters finished gevent.joinall(updaters, timeout=10) # Wait another 10 sec if none of updaters finished
self.log.debug("Queried listModifications from: %s in %s" % (queried, time.time() - s))
time.sleep(0.1) time.sleep(0.1)
self.log.debug("Queried listModifications from: %s" % queried)
return queried return queried
# Update content.json from peers and download changed files # Update content.json from peers and download changed files
# Return: None # Return: None
@util.Noparallel() @util.Noparallel()
def update(self, announce=False, check_files=False): def update(self, announce=False, check_files=False, since=None):
self.content_manager.loadContent("content.json", load_includes=False) # Reload content.json self.content_manager.loadContent("content.json", load_includes=False) # Reload content.json
self.content_updated = None # Reset content updated time self.content_updated = None # Reset content updated time
self.updateWebsocket(updating=True) self.updateWebsocket(updating=True)
@ -369,7 +370,7 @@ class Site(object):
if announce: if announce:
self.announce() self.announce()
queried = self.checkModifications() queried = self.checkModifications(since)
if check_files: if check_files:
self.storage.updateBadFiles(quick_check=True) # Quick check and mark bad files based on file size self.storage.updateBadFiles(quick_check=True) # Quick check and mark bad files based on file size

View file

@ -672,9 +672,9 @@ class UiWebsocket(object):
site.websockets.append(self) site.websockets.append(self)
# Update site content.json # Update site content.json
def actionSiteUpdate(self, to, address, check_files=False): def actionSiteUpdate(self, to, address, check_files=False, since=None):
def updateThread(): def updateThread():
site.update(check_files=check_files) site.update(check_files=check_files, since=since)
self.response(to, "Updated") self.response(to, "Updated")
site = self.server.sites.get(address) site = self.server.sites.get(address)