avoid generating web pages for bad manifests

master
Ken Barbour 2022-07-10 21:20:08 -04:00
parent b0967b12b3
commit 566cf1999b
2 changed files with 20 additions and 0 deletions

View File

@ -106,6 +106,10 @@ function publish_manifest() {
manifest=${1}
relpath=${2:-}
manifest_dir=$(dirname ${manifest})
validate_manifest "${manifest}" || {
logwarn "Invalid manifest: %s" "${manifest}"
return
}
for file in $(cat $manifest)
do
publish_file "${manifest_dir}/$file" "$relpath"
@ -218,6 +222,21 @@ function render_pass_image() {
template_subst CAPTION "${caption}"
}
function validate_manifest() {
local dir=$(dirname "${1}")
for file in `cat ${1}`
do
if [ ! -f ${dir}/${file} ]; then
logwarn "Missing file %s" "${dir}/${file}"
return 1
elif [ "$(wc -c <${dir}/${file})" -lt 5000 ]; then
logwarn "File too small %s" "${dir}/${file}"
return 2
fi
done
return 0
}
function timestamp_from_file() {
local filename=${1}
date -d "@$(stat -c '%Y' $filename)" '+%a %b %d %T %Z %Y'

View File

@ -150,6 +150,7 @@ test_render_page() {
assertTrue "expected 0 return status" ${rtrn}
assertNotNull "expected output to stdout" "`cat ${stdoutF}`"
assertNull 'unexpected message to stderr' "`cat ${stderrF}`"
cat $stderrF
assertNotNull 'expected wavfile in markup' "`grep 'noaa_15-1643805264.wav' ${stdoutF}`"
assertNotNull 'expected thermal image' "`grep 'noaa_15-1643805264-therm.png' ${stdoutF}`"