backuptool: Ensure to cleanup the environment on failure
Change-Id: I6f974a40b4f3f4a0a1f3a4b46bf8e0cfeb81c4ec
diff --git a/prebuilt/common/bin/backuptool_ab.sh b/prebuilt/common/bin/backuptool_ab.sh
index 6ca6f23..ca6b1f7 100755
--- a/prebuilt/common/bin/backuptool_ab.sh
+++ b/prebuilt/common/bin/backuptool_ab.sh
@@ -165,23 +165,30 @@
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
;;
*)