1
0
Fork 0
mirror of synced 2024-11-26 18:15:35 -05:00

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

View file

@ -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: