mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
helpers: fix non-atomic cache write
This was causing some values to be repeated more than once when using multiple tmux windows at the same time, for example for the RAM percentage in ram_percentage.sh. GitHub: fixes #62
This commit is contained in:
parent
9eb3dba666
commit
f609bed961
|
|
@ -130,8 +130,10 @@ put_cache_val() {
|
|||
val="${*:2}"
|
||||
tmpdir="$(get_tmp_dir)"
|
||||
[ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir"
|
||||
get_time >"$tmpdir/$key"
|
||||
echo -n "$val" >>"$tmpdir/$key"
|
||||
(
|
||||
get_time
|
||||
echo -n "$val"
|
||||
) >"$tmpdir/$key"
|
||||
echo -n "$val"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue