Fix overwriting newly installed portals with disabled portals

This commit is contained in:
pdamianik 2023-08-16 00:29:56 +02:00 committed by Mihai Fufezan
parent e8194a9bd8
commit d3f1a597c8
1 changed files with 11 additions and 1 deletions

View File

@ -122,11 +122,21 @@ disable_portal() {
mv "$ENABLED_PORTAL_DIR/$1.portal" "$DISABLED_PORTAL_DIR/$1.portal"
}
remove_disabled_portal() {
rm "$DISABLED_PORTAL_DIR/$1.portal"
}
PORTAL=$1
ENABLE=${2:-$(is_portal_enabled "$PORTAL" && echo "disable" || echo "enable")}
if [ "$ENABLE" = "enable" ]; then
is_portal_disabled "$PORTAL" && enable_portal "$PORTAL"
if is_portal_enabled "$PORTAL"; then
# remove disabled portal if enabled portal exists as well,
# as the enabled portal is most likely a newly installed version
is_portal_disabled "$PORTAL" && remove_disabled_portal "$PORTAL"
else
is_portal_disabled "$PORTAL" && enable_portal "$PORTAL"
fi
else
is_portal_enabled "$PORTAL" && disable_portal "$PORTAL"
fi