From d70b34cd0f1b0c9cf6218c8e17c4eac324e10486 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 2 Dec 2024 22:06:15 +0100 Subject: [PATCH] new: [vps] make ``vps odoo {dump|restore} ..`` aware of invalid ZIP files --- bin/vps | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bin/vps b/bin/vps index 7d467a8..dac6634 100755 --- a/bin/vps +++ b/bin/vps @@ -1709,6 +1709,16 @@ cmdline.spec:odoo:cmd:restore:run() { exit 1 } + if ! out=$(zip -T "$ZIP_DUMP_LOCATION" 2>&1); then + err "Dump file to restore is an invalid zip file." + if [ "$opt_debug" ]; then + printf "%s" "$out" | prefix " ${GRAY}|${NORMAL} " >&2 + else + echo " Use \`\`--debug\`\` (or \`\`-d\`\`) to get more information." >&2 + fi + exit 1 + fi + opts_compose=() [ -t 1 ] && opts_compose+=("--color") [ "$opt_debug" ] && { @@ -1775,6 +1785,14 @@ cmdline.spec:odoo:cmd:dump:run() { exit 1 } + if ! zip -T "$DUMP_ZIPFILE" >/dev/null; then + err "Dump produced an invalid zip file '$DUMP_ZIPFILE'. Deleting it." + echo " Note: if the database is too big, you may want to check that the" >&2 + echo " \`limit-time-*' parameters are not set to low." >&2 + rm -f "$DUMP_ZIPFILE" + exit 1 + fi + info "Successfully dumped ${DARKYELLOW}$odoo_service${NORMAL}'s $msg_dbname database to '$DUMP_ZIPFILE'." }