summaryrefslogtreecommitdiff
path: root/mirrors/management
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-12-11 09:06:47 -0600
committerDan McGee <dan@archlinux.org>2014-12-11 09:06:47 -0600
commit71c50a21fbb21f91253b552c3fbd9b7956261b69 (patch)
treeb513a979aa3940f18f7ba1a176eaf8efefc1c35c /mirrors/management
parent1a2709552704a91f9601a13c350153b3daf3a455 (diff)
Don't blow up if lastsync file wasn't correctly fetched
Instead, pass None value in which is handled accordingly. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/management')
-rw-r--r--mirrors/management/commands/mirrorcheck.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py
index d2a27bee..8c17c78f 100644
--- a/mirrors/management/commands/mirrorcheck.py
+++ b/mirrors/management/commands/mirrorcheck.py
@@ -96,7 +96,7 @@ def parse_lastsync(log, data):
try:
parsed_time = datetime.utcfromtimestamp(int(data))
log.last_sync = parsed_time.replace(tzinfo=utc)
- except ValueError:
+ except (TypeError, ValueError):
# it is bad news to try logging the lastsync value;
# sometimes we get a crazy-encoded web page.
# if we couldn't parse a time, this is a failure.
@@ -197,8 +197,11 @@ def check_rsync_url(mirror_url, location, timeout):
log.duration = None
else:
logger.debug("success: %s, %.2f", url, log.duration)
- with open(lastsync_path, 'r') as lastsync:
- parse_lastsync(log, lastsync.read())
+ if os.path.exists(lastsync_path):
+ with open(lastsync_path, 'r') as lastsync:
+ parse_lastsync(log, lastsync.read())
+ else:
+ parse_lastsync(log, None)
finally:
if os.path.exists(lastsync_path):
os.unlink(lastsync_path)