From 9495f9779c0604996cead68f2e083dbea4928b3c Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 6 Feb 2015 20:42:38 +0100 Subject: ext.shutil_generatorized: fixed #143 (copying of links) This bug was introduced in a986e2bd... --- ranger/ext/shutil_generatorized.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ranger/ext/shutil_generatorized.py b/ranger/ext/shutil_generatorized.py index 38e506a2..2df04926 100644 --- a/ranger/ext/shutil_generatorized.py +++ b/ranger/ext/shutil_generatorized.py @@ -103,6 +103,8 @@ def copy2(src, dst, overwrite=False, symlinks=False): dst = get_safe_path(dst) if symlinks and os.path.islink(src): linkto = os.readlink(src) + if overwrite and os.path.lexists(dst): + os.unlink(dst) os.symlink(linkto, dst) else: for _ in copyfile(src, dst): @@ -171,11 +173,10 @@ def copytree(src, dst, symlinks=False, ignore=None, overwrite=False): try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) - if os.path.lexists(dstname): - if not os.path.islink(dstname) \ - or os.readlink(dstname) != linkto: - os.unlink(dstname) - os.symlink(linkto, dstname) + if overwrite and os.path.lexists(dstname): + os.unlink(dstname) + os.symlink(linkto, dstname) + copystat(srcname, dstname) elif os.path.isdir(srcname): for _ in copytree(srcname, dstname, symlinks, ignore, overwrite): -- cgit 1.4.1-2-gfad0