Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check exit codes for commands in the browse_build function #3227

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Check exit codes for commands in the browse_build function
meganschanz committed Nov 16, 2023
commit 405a91390b809bbe5dedfc8656fb07d4b1615b81
43 changes: 36 additions & 7 deletions index-alphabetic-browse.sh
Original file line number Diff line number Diff line change
@@ -85,19 +85,48 @@ function build_browse

extra_jvm_opts=$4

# Get the browse headings
if [ "$skip_authority" = "1" ]; then
$JAVA ${extra_jvm_opts} -Dfile.encoding="UTF-8" -Dfield.preferred=heading -Dfield.insteadof=use_for -cp $CLASSPATH PrintBrowseHeadings "$bib_index" "$field" "${browse}.tmp"
if ! output=$($JAVA ${extra_jvm_opts} -Dfile.encoding="UTF-8" -Dfield.preferred=heading -Dfield.insteadof=use_for -cp $CLASSPATH PrintBrowseHeadings "$bib_index" "$field" "${browse}.tmp" 2>&1); then
echo "ERROR: Failed to create browse headings for ${browse}. ${output}."
exit 1
fi
else
$JAVA ${extra_jvm_opts} -Dfile.encoding="UTF-8" -Dfield.preferred=heading -Dfield.insteadof=use_for -cp $CLASSPATH PrintBrowseHeadings "$bib_index" "$field" "$auth_index" "${browse}.tmp"
if ! output=$($JAVA ${extra_jvm_opts} -Dfile.encoding="UTF-8" -Dfield.preferred=heading -Dfield.insteadof=use_for -cp $CLASSPATH PrintBrowseHeadings "$bib_index" "$field" "$auth_index" "${browse}.tmp" 2>&1); then
echo "ERROR: Failed to create browse headings for ${browse}. ${output}."
exit 1
fi
fi

sort -T /var/tmp -u -t$'\1' -k1 "${browse}.tmp" -o "sorted-${browse}.tmp"
$JAVA -Dfile.encoding="UTF-8" -cp $CLASSPATH CreateBrowseSQLite "sorted-${browse}.tmp" "${browse}_browse.db"
# Sort the browse headings
if ! output=$(sort -T /var/tmp -u -t$'\1' -k1 "${browse}.tmp" -o "sorted-${browse}.tmp" 2>&1); then
echo "ERROR: Failed to sort ${browse}. ${output}."
exit 1
fi

# Build the SQLite database
if ! output=$($JAVA -Dfile.encoding="UTF-8" -cp $CLASSPATH CreateBrowseSQLite "sorted-${browse}.tmp" "${browse}_browse.db" 2>&1); then
echo "ERROR: Failed to build the SQLite database for ${browse}. ${output}."
exit 1
fi

rm -f *.tmp
# Clear up temp files
if ! output=$(rm -f *.tmp 2>&1); then
echo "ERROR: Failed to clear out temp files for ${browse}. ${output}."
exit 1
fi

mv "${browse}_browse.db" "$index_dir/${browse}_browse.db-updated"
touch "$index_dir/${browse}_browse.db-ready"
# Move the new database to the index directory
if ! output=$(mv "${browse}_browse.db" "$index_dir/${browse}_browse.db-updated" 2>&1); then
echo "ERROR: Failed to move ${browse}_browse.db database to ${index_dir}/${browse}_browse.db-updated. ${output}."
exit 1
fi

# Indicate that the new database is ready for use
if ! output=$(touch "$index_dir/${browse}_browse.db-ready" 2>&1); then
echo "ERROR: Failed to mark the new ${browse} database as ready for use. ${error}."
exit 1
fi
}
# These parameters should match the ones in solr/vufind/biblio/conf/solrconfig.xml - BrowseRequestHandler
build_browse "hierarchy" "hierarchy_browse"