Fix bug with forced links not working in all cases
This commit fixes a bug where forced links did not work on certain types of bad links. Until this fix, forced links only worked if the original was a real file or directory. This commit fixes this, so that the forced link option also works when the original is a broken or incorrect symbolic link.
This commit is contained in:
parent
33d602bb93
commit
bc43348f42
1 changed files with 5 additions and 3 deletions
|
@ -27,7 +27,7 @@ class Linker(Executor):
|
||||||
if create:
|
if create:
|
||||||
success &= self._create(destination)
|
success &= self._create(destination)
|
||||||
if force:
|
if force:
|
||||||
success &= self._delete(destination)
|
success &= self._delete(path, destination)
|
||||||
else:
|
else:
|
||||||
path = source
|
path = source
|
||||||
success &= self._link(path, destination)
|
success &= self._link(path, destination)
|
||||||
|
@ -71,9 +71,11 @@ class Linker(Executor):
|
||||||
self._log.lowinfo('Creating directory %s' % parent)
|
self._log.lowinfo('Creating directory %s' % parent)
|
||||||
return success
|
return success
|
||||||
|
|
||||||
def _delete(self, path):
|
def _delete(self, source, path):
|
||||||
success = True
|
success = True
|
||||||
if self._exists(path) and not self._is_link(path):
|
source = os.path.join(self._base_directory, source)
|
||||||
|
if ((self._is_link(path) and self._link_destination(path) != source) or
|
||||||
|
(self._exists(path) and not self._is_link(path))):
|
||||||
fullpath = os.path.expanduser(path)
|
fullpath = os.path.expanduser(path)
|
||||||
try:
|
try:
|
||||||
if os.path.isdir(fullpath):
|
if os.path.isdir(fullpath):
|
||||||
|
|
Loading…
Reference in a new issue