diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-02-22 14:59:17 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-02-22 14:59:17 +0000 |
commit | d5fa85b98a213c5e8410a4a4556f65162d7ad2c7 (patch) | |
tree | 5c54feb55070639857813230e5a0a0bf36a4d4e2 /morphlib | |
parent | aa4834c1a911600ffa26b04285eb56cc863b63de (diff) | |
download | morph-d5fa85b98a213c5e8410a4a4556f65162d7ad2c7.tar.gz |
Make sure to remove cached git dirs if cloning/extracting fails.
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/sourcemanager.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/morphlib/sourcemanager.py b/morphlib/sourcemanager.py index f8314b8c..b4949ad4 100644 --- a/morphlib/sourcemanager.py +++ b/morphlib/sourcemanager.py @@ -14,10 +14,10 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import logging import os import urlparse import urllib2 +import shutil import string import morphlib @@ -124,6 +124,8 @@ class SourceManager(object): repo_url, self.msg) return cached_repo, None except morphlib.execute.CommandFailure, e: # pragma: no cover + if os.path.exists(cached_repo): + shutil.rmtree(cached_repo) self.msg('Unable to extract bundle %s' % bundle) return None, 'Unable to extract bundle %s: %s' % (bundle, e) @@ -148,6 +150,8 @@ class SourceManager(object): morphlib.git.clone(cached_repo, repo_url, self.msg) return cached_repo, None except morphlib.execute.CommandFailure, e: + if os.path.exists(cached_repo): # pragma: no cover + shutil.rmtree(cached_repo) return None, 'Unable to clone from %s: %s' % (repo_url, e) def _cache_repo_from_base_urls(self, repo, ref): |