From 44b9e1de0656e159921853abc2f6825bb0284da9 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 27 Feb 2024 08:12:51 +0000 Subject: [PATCH] Revert "Fix file.directory clobbering backupname path with test=True" This reverts commit 2f14cd2816656fbd1310b8ce882280ef96969e85. --- salt/states/file.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 3c6b28ad163..56a7ae2118f 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -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):