Skip to content
This repository
Browse code

Wrap parsing of dist file in a try/except block so we don't get an un…

…handled exception if the XML is invalid because of a partial or corrupt download (or Apple error).
  • Loading branch information...
commit c26918cd37b8b67d98ca84c14da14abde15b8288 1 parent 4b73a40
Greg Neagle gregneagle authored

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. +8 1 code/repo_sync
9 code/repo_sync
@@ -103,7 +103,12 @@ def parseSUdist(filename):
103 103 su_name = ""
104 104 title = ""
105 105
106   - dom = minidom.parse(filename)
  106 + try:
  107 + dom = minidom.parse(filename)
  108 + except ExpatError:
  109 + reposadocommon.print_stderr(
  110 + 'Invalid XML in %s', filename)
  111 + return None
107 112
108 113 choice_elements = dom.getElementsByTagName("choice")
109 114 if choice_elements:
@@ -631,6 +636,8 @@ def sync(fast_scan=False, download_packages=True):
631 636
632 637 if preferred_dist:
633 638 dist = parseSUdist(preferred_dist)
  639 + if not dist:
  640 + continue
634 641 products[product_key]['title'] = dist['title']
635 642 products[product_key]['version'] = dist['version']
636 643 products[product_key]['size'] = str(size)

0 comments on commit c26918c

Please sign in to comment.
Something went wrong with that request. Please try again.