"hold onto your butts." - Arnold, Jurassic Park

This commit is contained in:
brent s. 2020-09-04 13:16:24 -04:00
parent 1c8f4da1b1
commit cd29b8d13f
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
3 changed files with 19 additions and 3 deletions

View File

@ -38,15 +38,24 @@ class BaseFetcher(object):
for k, v in self.filechecks['remote'].items():
if v:
if self.mtime:
self.timestamps[k] = datetime.datetime.fromtimestamp(float(self.fetch_content(v.path, mtime_only = True)))
tstmp = self.fetch_content(v.path, mtime_only = True)
if not isinstance(tstmp, datetime.datetime):
self.timestamps[k] = None
continue
else:
self.timestamps[k] = datetime.datetime.fromtimestamp(float(tstmp))
else:
tstmp_raw = self.fetch_content(v.path).decode('utf-8').strip()
if tstmp_raw == '':
self.timestamps[k] = None
continue
if '%s' in v.fmt:
tstmp = datetime.datetime.fromtimestamp(float(tstmp_raw))
else:
tstmp = datetime.datetime.strptime(tstmp_raw, v.fmt)
self.timestamps[k] = tstmp
if self.offset:
newval = None
if self.offset.mod == '+' or not self.offset.mod:
newval = self.timestamps[k] + self.offset.offset
elif self.offset.mod == '-':

View File

@ -121,7 +121,7 @@ class RSync(_base.BaseFetcher):
if stdout != '':
_logger.debug('STDOUT: {0}'.format(stdout))
if stderr != '' or (rtrn != 0 and rtrn not in self.rsync_ignores):
err = rsync_returns.returns[rtrn]
err = rsync_returns.returns.get(rtrn, '(UNKNOWN ERROR)')
errmsg = 'Rsync to {0}:{1} returned'.format(self.domain, self.port)
debugmsg = 'Rsync command {0} returned'.format(' '.join(cmd_str))
if stderr != '':
@ -134,6 +134,7 @@ class RSync(_base.BaseFetcher):
_logger.error(errmsg)
_logger.debug(debugmsg)
warnings.warn(errmsg)
return(b'')
if mtime_only:
raw_content = datetime.datetime.fromtimestamp(os.stat(tf).st_mtime)
else:

View File

@ -314,7 +314,13 @@ class Distro(object):
update = u.fetcher.timestamps.get('update')
sync = u.fetcher.timestamps.get('sync')
if update:
if local_checks and (local_checks[-1] < update):
if self.timestamps.get('update'):
if self.timestamps['update'] < update:
_logger.info('Local update timestamp is older than the remote update; syncing.')
_logger.debug('Local update: {0}, remote update: {1}'.format(self.timestamps['update'],
update))
u.has_new = True
elif local_checks and (local_checks[-1] < update):
_logger.info('Newest local timestamp is older than the remote update; syncing.')
_logger.debug('Newest local: {0}, remote update: {1}'.format(local_checks[-1], update))
u.has_new = True