mirror of
1
0
Fork 0

Add call to Link._backup into Link._delete

This commit is contained in:
c-c-k 2023-07-18 06:08:15 +03:00
parent 4121157c8d
commit 1f65810dc5
1 changed files with 7 additions and 2 deletions

View File

@ -246,7 +246,7 @@ class Link(Plugin):
self._log.lowinfo("Creating directory %s" % parent)
return success
def _delete(self, source, path, relative, canonical_path, force):
def _delete(self, source, path, relative, canonical_path, force, backup_root):
success = True
source = os.path.join(self._context.base_directory(canonical_path=canonical_path), source)
fullpath = os.path.abspath(os.path.expanduser(path))
@ -256,8 +256,13 @@ class Link(Plugin):
self._exists(path) and not self._is_link(path)
):
removed = False
if backup_root:
backed_up = self._backup(path, backup_root)
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)
removed = True
elif force: