fix(util): open lock file in append mode to avoid overwriting files
Previously if we opened a lock on an existing file with useful content we overwrote it with an empty file. This is obviously not desired, hence open the file handle in append mode preserving its content. Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
parent
4673ad6c89
commit
0e538cf498
|
@ -135,7 +135,7 @@ lock() {
|
|||
# Only reopen the FD if it wasn't handed to us
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
eval "exec $1>>"'"$2"'
|
||||
fi
|
||||
|
||||
if ! flock -n "$1"; then
|
||||
|
|
Loading…
Reference in New Issue