Add call to Link._backup into Link._delete
This commit is contained in:
parent
4121157c8d
commit
1f65810dc5
1 changed files with 7 additions and 2 deletions
|
@ -246,7 +246,7 @@ class Link(Plugin):
|
||||||
self._log.lowinfo("Creating directory %s" % parent)
|
self._log.lowinfo("Creating directory %s" % parent)
|
||||||
return success
|
return success
|
||||||
|
|
||||||
def _delete(self, source, path, relative, canonical_path, force):
|
def _delete(self, source, path, relative, canonical_path, force, backup_root):
|
||||||
success = True
|
success = True
|
||||||
source = os.path.join(self._context.base_directory(canonical_path=canonical_path), source)
|
source = os.path.join(self._context.base_directory(canonical_path=canonical_path), source)
|
||||||
fullpath = os.path.abspath(os.path.expanduser(path))
|
fullpath = os.path.abspath(os.path.expanduser(path))
|
||||||
|
@ -256,8 +256,13 @@ class Link(Plugin):
|
||||||
self._exists(path) and not self._is_link(path)
|
self._exists(path) and not self._is_link(path)
|
||||||
):
|
):
|
||||||
removed = False
|
removed = False
|
||||||
|
if backup_root:
|
||||||
|
backed_up = self._backup(path, backup_root)
|
||||||
try:
|
try:
|
||||||
if os.path.islink(fullpath):
|
if backup_root and not backed_up:
|
||||||
|
self._log.warning("Skipping removal of %s due to failed backup" % path)
|
||||||
|
success = False
|
||||||
|
elif os.path.islink(fullpath):
|
||||||
os.unlink(fullpath)
|
os.unlink(fullpath)
|
||||||
removed = True
|
removed = True
|
||||||
elif force:
|
elif force:
|
||||||
|
|
Loading…
Reference in a new issue