From fc8d478060b2168771650b4f68ac9890a8ead1fa Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Sat, 31 May 2014 23:22:28 -0400 Subject: [PATCH] Untested fix #33. Add: bitshift/crawler/indexer.py -Add conditional to remove the full path of a repository if the owner's directory contains only one sub-directory. --- bitshift/crawler/indexer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bitshift/crawler/indexer.py b/bitshift/crawler/indexer.py index b5b64eb..5a351c0 100644 --- a/bitshift/crawler/indexer.py +++ b/bitshift/crawler/indexer.py @@ -121,7 +121,12 @@ class GitIndexer(threading.Thread): self._logger.exception("Exception raised while indexing:") finally: if os.path.isdir("%s/%s" % (GIT_CLONE_DIR, repo.name)): - shutil.rmtree("%s/%s" % (GIT_CLONE_DIR, repo.name)) + if len([obj for obj in os.listdir('.') if + os.path.isdir(obj)]) <= 1: + shutil.rmtree("%s/%s" % ( + GIT_CLONE_DIR, repo.name.split("/")[0])) + else: + shutil.rmtree("%s/%s" % (GIT_CLONE_DIR, repo.name)) def _insert_repository_codelets(self, repo): """