Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2024-01-05 13:38:19 +0100
committerLevente Polyak <anthraxx@archlinux.org>2024-01-07 02:38:34 +0100
commit0e538cf4983f27548077c0a2a272ecd8deebacb1 (patch)
tree850aba2689c6e0b924f5f99eea4cb2a39e5b6ee3
parent4673ad6c89bbdca632b22edfc2ef35486b7a635b (diff)
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>
-rw-r--r--src/lib/common.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/common.sh b/src/lib/common.sh
index 82fdd2e..29b0343 100644
--- a/src/lib/common.sh
+++ b/src/lib/common.sh
@@ -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