Rev2025, Publish remotely outdated files on modification check

This commit is contained in:
shortcutme 2017-04-07 21:17:25 +02:00
parent e1f7752aff
commit 03f3e9e4fd
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
2 changed files with 11 additions and 6 deletions

View File

@ -10,7 +10,7 @@ class Config(object):
def __init__(self, argv):
self.version = "0.5.3"
self.rev = 2023
self.rev = 2025
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"

View File

@ -303,11 +303,16 @@ class Site(object):
modified_contents = []
my_modified = self.content_manager.listModified(since)
for inner_path, modified in res["modified_files"].iteritems(): # Check if the peer has newer files than we
newer = int(modified) > my_modified.get(inner_path, 0)
if newer and inner_path not in self.bad_files and not self.content_manager.isArchived(inner_path, modified):
# We dont have this file or we have older
modified_contents.append(inner_path)
self.bad_files[inner_path] = self.bad_files.get(inner_path, 0) + 1
has_newer = int(modified) > my_modified.get(inner_path, 0)
has_older = int(modified) < my_modified.get(inner_path, 0)
if inner_path not in self.bad_files and not self.content_manager.isArchived(inner_path, modified):
if has_newer:
# We dont have this file or we have older
modified_contents.append(inner_path)
self.bad_files[inner_path] = self.bad_files.get(inner_path, 0) + 1
if has_older:
self.log.debug("%s client has older version of %s, publishing there..." % (peer, inner_path))
gevent.spawn(self.publisher, inner_path, [peer], [], 1)
if modified_contents:
self.log.debug("%s new modified file from %s" % (len(modified_contents), peer))
modified_contents.sort(key=lambda inner_path: 0 - res["modified_files"][inner_path]) # Download newest first