fix a detail with the new app restore process (#1812)

Signed-off-by: szaimen <szaimen@e.mail.de>

Co-authored-by: Daniel Hansson <github@hanssonit.se>
This commit is contained in:
szaimen 2021-02-12 19:37:54 +01:00 committed by GitHub
parent ca2a6ae536
commit cfc833579b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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