Don't complete the update if there is no datasource or if writing to cache fails

This commit is contained in:
Joshua Harlow 2012-06-22 23:43:48 -07:00
parent 46baea3ead
commit e06021a61b

View File

@ -178,10 +178,13 @@ class Init(object):
return None return None
def _write_to_cache(self): def _write_to_cache(self):
if not self.datasource:
return False
pickled_fn = self.paths.get_ipath_cur("obj_pkl") pickled_fn = self.paths.get_ipath_cur("obj_pkl")
try: try:
contents = pickle.dumps(self.datasource) contents = pickle.dumps(self.datasource)
util.write_file(pickled_fn, contents, mode=0400) util.write_file(pickled_fn, contents, mode=0400)
return True
except Exception: except Exception:
util.logexc(LOG, "Failed pickling datasource to %s", pickled_fn) util.logexc(LOG, "Failed pickling datasource to %s", pickled_fn)
return False return False
@ -292,7 +295,8 @@ class Init(object):
self.distro, helpers.Runners(self.paths)) self.distro, helpers.Runners(self.paths))
def update(self): def update(self):
self._write_to_cache() if not self._write_to_cache():
return
self._store_userdata() self._store_userdata()
def _store_userdata(self): def _store_userdata(self):