Revert "Fix file.directory clobbering backupname path with test=True"

This reverts commit 2f14cd2816.
This commit is contained in:
Pedro Algarvio 2024-02-27 08:12:51 +00:00
parent 856ac3545e
commit 44b9e1de06

View file

@ -3901,25 +3901,13 @@ def directory(
if not force:
return _error(
ret,
f"File exists where the backup target {backupname} should go",
"File exists where the backup target {} should go".format(
backupname
),
)
if __opts__["test"]:
ret["changes"][
"forced"
] = f"Existing file at backup path {backupname} would be removed"
else:
__salt__["file.remove"](backupname)
if __opts__["test"]:
ret["changes"]["backup"] = f"{name} would be renamed to {backupname}"
ret["changes"][name] = {"directory": "new"}
ret[
"comment"
] = f"{name} would be backed up and replaced with a new directory"
ret["result"] = None
return ret
else:
os.rename(name, backupname)
os.rename(name, backupname)
elif force:
# Remove whatever is in the way
if os.path.isfile(name):