summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCheuk Leung <cheuk.leung.consultant@gmail.com>2015-07-06 21:33:00 +0200
committerDavid Pursehouse <dpursehouse@collab.net>2016-06-29 05:43:01 +0000
commit8ac0c96537f876127be879d0931ede1545f93d34 (patch)
treef98ae2391f541900934c74df232de5abf5dace0d
parentfaaddc9b4e4c6f6cbac02e90415676fabd177b99 (diff)
downloadgit-repo-8ac0c96537f876127be879d0931ede1545f93d34.tar.gz
Fix removing broken symlink in reference dir
Re-ordered to first create the symlink before checking the source file and remove the destination if the source does not exists. Change-Id: Iae923ba2ef0ba5a8dc1b8e42d8cc3f3708f773af
-rw-r--r--project.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/project.py b/project.py
index c91085c3..9a7128af 100644
--- a/project.py
+++ b/project.py
@@ -2373,6 +2373,14 @@ class Project(object):
2373 if name in symlink_dirs and not os.path.lexists(src): 2373 if name in symlink_dirs and not os.path.lexists(src):
2374 os.makedirs(src) 2374 os.makedirs(src)
2375 2375
2376 if name in to_symlink:
2377 os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
2378 elif copy_all and not os.path.islink(dst):
2379 if os.path.isdir(src):
2380 shutil.copytree(src, dst)
2381 elif os.path.isfile(src):
2382 shutil.copy(src, dst)
2383
2376 # If the source file doesn't exist, ensure the destination 2384 # If the source file doesn't exist, ensure the destination
2377 # file doesn't either. 2385 # file doesn't either.
2378 if name in symlink_files and not os.path.lexists(src): 2386 if name in symlink_files and not os.path.lexists(src):
@@ -2381,13 +2389,6 @@ class Project(object):
2381 except OSError: 2389 except OSError:
2382 pass 2390 pass
2383 2391
2384 if name in to_symlink:
2385 os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
2386 elif copy_all and not os.path.islink(dst):
2387 if os.path.isdir(src):
2388 shutil.copytree(src, dst)
2389 elif os.path.isfile(src):
2390 shutil.copy(src, dst)
2391 except OSError as e: 2392 except OSError as e:
2392 if e.errno == errno.EPERM: 2393 if e.errno == errno.EPERM:
2393 raise DownloadError('filesystem must support symlinks') 2394 raise DownloadError('filesystem must support symlinks')