From b5f3a4a72d30307b5b56a381f36d49d4136cbb36 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Sun, 21 Mar 2021 11:39:06 +0100 Subject: [PATCH] backuptool: Ensure to cleanup the environment on failure Change-Id: I6f974a40b4f3f4a0a1f3a4b46bf8e0cfeb81c4ec --- prebuilt/common/bin/backuptool_ab.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/prebuilt/common/bin/backuptool_ab.sh b/prebuilt/common/bin/backuptool_ab.sh index ee7b906a..a518e9c0 100755 --- a/prebuilt/common/bin/backuptool_ab.sh +++ b/prebuilt/common/bin/backuptool_ab.sh @@ -164,23 +164,30 @@ umount_extra() { done } +cleanup() { + umount_extra $all_V3_partitions + umount /postinstall/tmp + rm -rf /postinstall/tmp +} + case "$1" in backup) if check_prereq; then mkdir -p $C preserve_addon_d run_stages pre-backup backup post-backup + else + cleanup fi ;; restore) if check_prereq; then run_stages pre-restore restore post-restore - umount_extra $all_V3_partitions restore_addon_d - rm -rf $C - umount /postinstall/tmp - rm -rf /postinstall/tmp + cleanup sync + else + cleanup fi ;; *)