Add core userdata backup option to post_update and give user option to exit update process if backup fails

This commit is contained in:
icenine451 2025-03-26 11:07:45 -04:00
parent 2004cc7a3e
commit fafba97ad4

View file

@ -23,7 +23,13 @@ post_update() {
case $choice in
"Backup Core Userdata" )
log i "User chose to backup core userdata prior to update."
backup_retrodeck_userdata "core"
if ! backup_retrodeck_userdata "core"; then
log d "Userdata backup failed, giving option to proceed"
if [[ $(configurator_generic_question_dialog "RetroDECK Update" "Unfortunately the userdata backup process was not successful.\nWould you like to proceed with the upgrade anyway?\n\nRetroDECK will exit if you choose \"No\"") == "false" ]]; then
log d "User chose to stop post_update process after backup failure"
exit 1
fi
fi
;;
"Backup Some Userdata" )
log i "User chose to backup some userdata prior to update."
@ -50,11 +56,23 @@ post_update() {
choices=() # Expand choice string into passable array
IFS='^' read -ra choices <<< "$choice"
backup_retrodeck_userdata "custom" "${choices[@]}" # Expand array of choices into individual arguments
if ! backup_retrodeck_userdata "custom" "${choices[@]}"; then # Expand array of choices into individual arguments
log d "Userdata backup failed, giving option to proceed"
if [[ $(configurator_generic_question_dialog "RetroDECK Update" "Unfortunately the userdata backup process was not successful.\nWould you like to proceed with the upgrade anyway?\n\nRetroDECK will exit if you choose \"No\"") == "false" ]]; then
log d "User chose to stop post_update process after backup failure"
exit 1
fi
fi
;;
"Backup All Userdata" )
log i "User chose to backup all userdata prior to update."
backup_retrodeck_userdata "complete"
if ! backup_retrodeck_userdata "complete"; then
log d "Userdata backup failed, giving option to proceed"
if [[ $(configurator_generic_question_dialog "RetroDECK Update" "Unfortunately the userdata backup process was not successful.\nWould you like to proceed with the upgrade anyway?\n\nRetroDECK will exit if you choose \"No\"") == "false" ]]; then
log d "User chose to stop post_update process after backup failure"
exit 1
fi
fi
;;
esac
fi