From cfc833579b8d358f74221b23773aebabcd0b21cd Mon Sep 17 00:00:00 2001 From: szaimen Date: Fri, 12 Feb 2021 19:37:54 +0100 Subject: [PATCH] fix a detail with the new app restore process (#1812) Signed-off-by: szaimen Co-authored-by: Daniel Hansson --- nextcloud_update.sh | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/nextcloud_update.sh b/nextcloud_update.sh index 9f7f7dcf..a28c50ed 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -778,13 +778,41 @@ then print_text_in_color "$ICyan" "Restoring the status of apps. This can take a while..." for app in "${!APPSTORAGE[@]}" do - if ! is_app_installed "$app" + if [ -n "${APPSTORAGE[$app]}" ] then - nextcloud_occ_no_check app:install "$app" - fi - if [ -n "${APPSTORAGE[$app]}" ] && [ "${APPSTORAGE[$app]}" != "yes" ] && is_app_enabled "$app" - then - nextcloud_occ_no_check config:app:set "$app" enabled --value="${APPSTORAGE[$app]}" + # Check if the app is in Nextclouds app storage + if ! [ -d "$NC_APPS_PATH/$app" ] + then + # If the app is missing from the apps folder and was installed and enabled before the upgrade was done, + # then reinstall it + if [ "${APPSTORAGE[$app]}" = "yes" ] + then + install_and_enable_app "$app" + # If the app is missing from the apps folder and was installed but not enabled before the upgrade was done, + # then reinstall it but keep it disabled + elif [ "${APPSTORAGE[$app]}" = "no" ] + then + install_and_enable_app "$app" + nextcloud_occ_no_check app:disable "$app" + # Cover the case where the app is enabled for certain groups + else + install_and_enable_app "$app" + if is_app_enabled "$app" + then + # Only restore the group settings, if the app was enabled (and is thus compatible with the new NC version) + nextcloud_occ_no_check config:app:set "$app" enabled --value="${APPSTORAGE[$app]}" + fi + fi + fi + # If the app still isn't enabled (maybe because it's incompatible), then at least restore from backup, + # and make sure it's disabled + if ! [ -d "$NC_APPS_PATH/$app" ] && [ -d "$BACKUP/apps/$app" ] + then + print_text_in_color "$ICyan" "Restoring $app from $BACKUP/apps..." + rsync -Aaxz "$BACKUP/apps/$app" "$NC_APPS_PATH/" + bash "$SECURE" + nextcloud_occ_no_check app:disable "$app" + fi fi done fi