summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-11-04 10:22:20 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-11-04 10:22:20 -0500
commit59d3bf19201cabe85862dfa5bbaaa5898162357e (patch)
tree9580cebb9946fb3a251f6eb382ea20208c925cfe /src
parente08f9951f53d5acf35389e6d9975f976fc1f7c99 (diff)
downloadbcfg2-59d3bf19201cabe85862dfa5bbaaa5898162357e.tar.gz
bcfg2-59d3bf19201cabe85862dfa5bbaaa5898162357e.tar.bz2
bcfg2-59d3bf19201cabe85862dfa5bbaaa5898162357e.zip
VCS: Fix traceback when destination directory exists
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/Client/Tools/VCS.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/Client/Tools/VCS.py b/src/lib/Client/Tools/VCS.py
index fa7748574..e6081dc1c 100644
--- a/src/lib/Client/Tools/VCS.py
+++ b/src/lib/Client/Tools/VCS.py
@@ -7,6 +7,7 @@
missing = []
import os
+import shutil
import sys
# python-dulwich git imports
try:
@@ -62,6 +63,18 @@ class VCS(Bcfg2.Client.Tools.Tool):
def Installgit(self, entry):
"""Checkout contents from a git repository"""
destname = entry.get('name')
+ if os.path.lexists(destname):
+ # remove incorrect contents
+ try:
+ if os.path.isdir(destname):
+ shutil.rmtree(destname)
+ else:
+ os.remove(destname)
+ except OSError:
+ self.logger.info('Failed to remove %s' % \
+ destname)
+ return False
+
destr = dulwich.repo.Repo.init(destname, mkdir=True)
cl, host_path = dulwich.client.get_transport_and_path(entry.get('sourceurl'))
remote_refs = cl.fetch(host_path,