1 |
commit: 0bb79addc38cc95fd0e98b681ea7c626f0d7d21b |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 2 06:14:19 2021 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 2 06:14:19 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/build-docbook-catalog.git/commit/?id=0bb79add |
7 |
|
8 |
handle corrupt catalogs gracefully |
9 |
|
10 |
If the files get corrupted for any reason (i.e. are not valid XML), |
11 |
the current code gets wedged and is unable to recover until the user |
12 |
deletes or fixes them. Instead, let's throw them away and start over. |
13 |
|
14 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
15 |
|
16 |
build-docbook-catalog | 10 ++++++++++ |
17 |
1 file changed, 10 insertions(+) |
18 |
|
19 |
diff --git a/build-docbook-catalog b/build-docbook-catalog |
20 |
index 1c7f103..6950f3e 100755 |
21 |
--- a/build-docbook-catalog |
22 |
+++ b/build-docbook-catalog |
23 |
@@ -161,6 +161,11 @@ multi_xmlcatalog_add() { |
24 |
create_catalogs() { |
25 |
local adds |
26 |
|
27 |
+ # Initialize catalogs if they don't exist or are corrupt. |
28 |
+ if ! xmllint "${ROOT}${ROOTCATALOG}" >&/dev/null ; then |
29 |
+ rm -f "${ROOTCATALOG}" |
30 |
+ echo "Deleting corrupt ${ROOT}${ROOTCATALOG} and starting over" |
31 |
+ fi |
32 |
if [[ ! -r ${ROOT}${ROOTCATALOG} ]] ; then |
33 |
echo "Creating XML Catalog root ${ROOTCATALOG}" |
34 |
xmlcatalog --noout --create "${ROOT}${ROOTCATALOG}" |
35 |
@@ -174,6 +179,11 @@ create_catalogs() { |
36 |
clean_catalog "file://${CATALOG}" "${ROOTCATALOG}" |
37 |
fi |
38 |
|
39 |
+ # Initialize catalogs if they don't exist or are corrupt. |
40 |
+ if ! xmllint "${ROOT}${CATALOG}" >&/dev/null ; then |
41 |
+ rm -f "${ROOT}${CATALOG}" |
42 |
+ echo "Deleting corrupt ${CATALOG} and starting over" |
43 |
+ fi |
44 |
if [[ ! -r ${ROOT}${CATALOG} ]] ; then |
45 |
echo "Creating DocBook XML Catalog ${CATALOG}" |
46 |
xmlcatalog --noout --create "${ROOT}${CATALOG}" |