More optimization.

This commit is contained in:
Narendra Ingale 2017-03-17 21:20:29 +05:30 committed by rallytime
parent 5a08266814
commit cf1857904b

View file

@ -2060,14 +2060,9 @@ def directory(name,
return _error(
ret, 'Specified file {0} is not an absolute path'.format(name))
# checkng if bad symlink and force is applied
bad_link = False
if os.path.islink(name) and force:
if not os.path.exists(os.readlink(name)):
bad_link = True
# Check for existing file or symlink
if os.path.isfile(name) or (not allow_symlink and os.path.islink(name)) or bad_link:
if os.path.isfile(name) or (not allow_symlink and os.path.islink(name)) \
or (force and os.path.islink(name)):
# Was a backupname specified
if backupname is not None:
# Make a backup first