still not syncing properly...

This commit is contained in:
brent s. 2020-06-24 01:15:56 -04:00
parent c8bf61ea98
commit 2ff334f220
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 10 additions and 3 deletions

View File

@ -31,7 +31,7 @@ class BaseFetcher(object):
else: else:
tstmp = datetime.datetime.strptime(tstmp_raw, v.fmt) tstmp = datetime.datetime.strptime(tstmp_raw, v.fmt)
self.timestamps[k] = tstmp self.timestamps[k] = tstmp
_logger.debug('Updated timestamps: {0}'.format(self.timestamps)) _logger.debug('Updated upstream timestamps: {0}'.format(self.timestamps))
return(None) return(None)


def fetch_content(self, path): def fetch_content(self, path):

View File

@ -229,23 +229,30 @@ class Distro(object):
if v: if v:
tstmp = v.read() tstmp = v.read()
self.timestamps[k] = tstmp self.timestamps[k] = tstmp
_logger.debug('Updated timestamps: {0}'.format(self.timestamps)) _logger.debug('Updated local timestamps: {0}'.format(self.timestamps))
local_checks = sorted([i for i in self.timestamps.values() if i]) local_checks = sorted([i for i in self.timestamps.values() if i])
if local_checks:
_logger.debug('Local timestamps: {0}'.format(', '.join([str(t) for t in local_checks])))
for u in self.upstreams: for u in self.upstreams:
if not u.available: if not u.available:
continue continue
u.fetcher.check() u.fetcher.check()
remote_checks = sorted([i for i in u.fetcher.timestamps.values() if i]) remote_checks = sorted([i for i in u.fetcher.timestamps.values() if i])
if remote_checks:
_logger.debug('Remote timestamps for {0}: {1}'.format(u.domain, ', '.join([str(t)
for t in remote_checks])))
if not any((local_checks, remote_checks)) or not remote_checks: if not any((local_checks, remote_checks)) or not remote_checks:
u.has_new = True u.has_new = True
else: else:
update = u.fetcher.timestamps.get('update') update = u.fetcher.timestamps.get('update')
sync = u.fetcher.timestamps.get('sync') sync = u.fetcher.timestamps.get('sync')
if update: if update:
if local_checks and local_checks[-1] < update: if local_checks and (local_checks[-1] < update):
u.has_new = True u.has_new = True
elif not local_checks: elif not local_checks:
u.has_new = True u.has_new = True
else:
u.has_new = True
if sync: if sync:
td = datetime.datetime.utcnow() - sync td = datetime.datetime.utcnow() - sync
if td.days > constants.DAYS_WARN: if td.days > constants.DAYS_WARN: