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:
19
yadm
19
yadm
@@ -489,20 +489,15 @@ function move_file() {
|
||||
local output=$2
|
||||
local temp_file=$3
|
||||
|
||||
if [ ! -f "$temp_file" ] ; then
|
||||
return 0
|
||||
fi
|
||||
[ ! -f "$temp_file" ] && return
|
||||
|
||||
# if the output files already exists as read-only, change it to be writable.
|
||||
# there are some environments in which a read-only file will prevent the move
|
||||
# from being successful.
|
||||
[[ -e "$output" && ! -w "$output" ]] && chmod u+w "$output"
|
||||
|
||||
local read_only
|
||||
copy_perms "$input" "$temp_file"
|
||||
if [[ -e "$output" && ! -w "$output" ]]; then
|
||||
read_only=1
|
||||
chmod u+w "$output"
|
||||
fi
|
||||
mv -f "$temp_file" "$output"
|
||||
if [ -n "$read_only" ]; then
|
||||
chmod u-w "$output"
|
||||
fi
|
||||
copy_perms "$input" "$output"
|
||||
}
|
||||
|
||||
# ****** yadm Commands ******
|
||||
|
||||
Reference in New Issue
Block a user