mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
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
This commit is contained in:
parent
faaddc9b4e
commit
8ac0c96537
15
project.py
15
project.py
@ -2373,6 +2373,14 @@ class Project(object):
|
|||||||
if name in symlink_dirs and not os.path.lexists(src):
|
if name in symlink_dirs and not os.path.lexists(src):
|
||||||
os.makedirs(src)
|
os.makedirs(src)
|
||||||
|
|
||||||
|
if name in to_symlink:
|
||||||
|
os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
|
||||||
|
elif copy_all and not os.path.islink(dst):
|
||||||
|
if os.path.isdir(src):
|
||||||
|
shutil.copytree(src, dst)
|
||||||
|
elif os.path.isfile(src):
|
||||||
|
shutil.copy(src, dst)
|
||||||
|
|
||||||
# If the source file doesn't exist, ensure the destination
|
# If the source file doesn't exist, ensure the destination
|
||||||
# file doesn't either.
|
# file doesn't either.
|
||||||
if name in symlink_files and not os.path.lexists(src):
|
if name in symlink_files and not os.path.lexists(src):
|
||||||
@ -2381,13 +2389,6 @@ class Project(object):
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if name in to_symlink:
|
|
||||||
os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
|
|
||||||
elif copy_all and not os.path.islink(dst):
|
|
||||||
if os.path.isdir(src):
|
|
||||||
shutil.copytree(src, dst)
|
|
||||||
elif os.path.isfile(src):
|
|
||||||
shutil.copy(src, dst)
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EPERM:
|
if e.errno == errno.EPERM:
|
||||||
raise DownloadError('filesystem must support symlinks')
|
raise DownloadError('filesystem must support symlinks')
|
||||||
|
Loading…
Reference in New Issue
Block a user