summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrent s <bts@square-r00t.net>2020-09-04 13:16:24 -0400
committerbrent s <bts@square-r00t.net>2020-09-04 13:16:24 -0400
commitcd29b8d13f440c61fd954268fdf55a57191713df (patch)
treef281472302b3f48900ff06ccf0bbf09033adcd72
parent1c8f4da1b1b27ee7cc6920fbfbea30ca33a2fe3c (diff)
downloadRepoMirror-cd29b8d13f440c61fd954268fdf55a57191713df.tar.xz
"hold onto your butts." - Arnold, Jurassic Park
-rw-r--r--repomirror/fetcher/_base.py11
-rw-r--r--repomirror/fetcher/rsync.py3
-rw-r--r--repomirror/sync.py8
3 files changed, 19 insertions, 3 deletions
diff --git a/repomirror/fetcher/_base.py b/repomirror/fetcher/_base.py
index d9d7d21..8284f07 100644
--- a/repomirror/fetcher/_base.py
+++ b/repomirror/fetcher/_base.py
@@ -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 == '-':
diff --git a/repomirror/fetcher/rsync.py b/repomirror/fetcher/rsync.py
index 230dfba..2d018d8 100644
--- a/repomirror/fetcher/rsync.py
+++ b/repomirror/fetcher/rsync.py
@@ -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:
diff --git a/repomirror/sync.py b/repomirror/sync.py
index 8d5f59c..2b554b1 100644
--- a/repomirror/sync.py
+++ b/repomirror/sync.py
@@ -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