Ensure atomic write to the output file
This commit is contained in:
parent
4645874c82
commit
e68569bc81
1 changed files with 3 additions and 1 deletions
|
|
@ -21,11 +21,13 @@ extension="${picture_url##*.}"
|
||||||
filename="${picture_date}.${extension}"
|
filename="${picture_date}.${extension}"
|
||||||
outfile="${WALLPAPERS}/${filename}"
|
outfile="${WALLPAPERS}/${filename}"
|
||||||
|
|
||||||
|
tempfile="$(mktemp)"
|
||||||
curl \
|
curl \
|
||||||
--location \
|
--location \
|
||||||
--output "${outfile}" \
|
--output "${tempfile}" \
|
||||||
--silent \
|
--silent \
|
||||||
"${picture_url}"
|
"${picture_url}"
|
||||||
|
mv "${tempfile}" "${outfile}"
|
||||||
ln \
|
ln \
|
||||||
--force \
|
--force \
|
||||||
--symbolic \
|
--symbolic \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue