mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Revert "Fix file.directory clobbering backupname path with test=True"
This reverts commit 2f14cd2816
.
This commit is contained in:
parent
856ac3545e
commit
44b9e1de06
1 changed files with 4 additions and 16 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue