File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,16 @@ set -o pipefail
3232
3333# Make sure to move snapshot contents to the WORKING_SNAPSHOT location. Then allow jq to
3434# work with it there. This avoids having to read SNAPSHOT to memory.
35+ # Always use a temp file for WORKING_SNAPSHOT to avoid truncation issues when writing
36+ # the final output to SNAPSHOT_PATH (which may be the same file as SNAPSHOT).
3537
38+ WORKING_SNAPSHOT=" $( mktemp " ${HOME:-/ tmp} /snapshot.XXXXXX" ) "
3639if [[ -f " $SNAPSHOT " ]]; then
37- WORKING_SNAPSHOT= " $SNAPSHOT "
40+ cp " $SNAPSHOT " " $WORKING_SNAPSHOT "
3841else
39- WORKING_SNAPSHOT=" $( mktemp " ${HOME:-/ tmp} /snapshot.XXXXXX" ) "
4042 printf " %s" " $SNAPSHOT " > " $WORKING_SNAPSHOT "
4143fi
44+
4245jq empty " $WORKING_SNAPSHOT " || { echo " JSON is invalid" ; exit 1; }
4346
4447echo " Single Component mode? ${SINGLE_COMPONENT} "
You can’t perform that action at this time.
0 commit comments