1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Adjust special handling of existing read-only output files

Instead of duplicating the permissions on the temp file, the permissions
are duplicated on the output file directly. If the output file exists as
read-only, it is made writeable first.

There are some environments which don't allow the mv to work if the file
itself is read-only.
This commit is contained in:
Tim Byrne
2021-02-28 10:55:37 -06:00
parent 39773765ab
commit 216aed2f87
4 changed files with 25 additions and 12 deletions

View File

@@ -127,6 +127,12 @@ def test_template_default(runner, yadm, tmpdir):
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
# ensure overwrite works when file exists as read-only (there is some
# special processing when this is encountered because some environments do
# not properly overwrite read-only files)
output_file.write('existing')
output_file.chmod(0o400)
script = f"""
YADM_TEST=1 source {yadm}
set_awk

View File

@@ -86,6 +86,12 @@ def test_template_esh(runner, yadm, tmpdir):
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
# ensure overwrite works when file exists as read-only (there is some
# special processing when this is encountered because some environments do
# not properly overwrite read-only files)
output_file.write('existing')
output_file.chmod(0o400)
script = f"""
YADM_TEST=1 source {yadm}
local_class="{LOCAL_CLASS}"

View File

@@ -88,6 +88,12 @@ def test_template_j2(runner, yadm, tmpdir, processor):
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
# ensure overwrite works when file exists as read-only (there is some
# special processing when this is encountered because some environments do
# not properly overwrite read-only files)
output_file.write('existing')
output_file.chmod(0o400)
script = f"""
YADM_TEST=1 source {yadm}
local_class="{LOCAL_CLASS}"