Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.py, helpers: Reword YNH_APP_UPGRADE_TYPE #1762

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions helpers/utils
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ ynh_setup_source() {
if test -e "$local_src"; then
cp $local_src $src_filename
fi

[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"

# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
Expand Down Expand Up @@ -990,15 +990,11 @@ ynh_app_package_version() {
# This helper should be used to avoid an upgrade of an app, or the upstream part
# of it, when it's not needed
#
# You can force an upgrade, even if the package is up to date, with the `--force` (or `-F`) argument :
# ```
# sudo yunohost app upgrade <appname> --force
# ```
# Requires YunoHost version 3.5.0 or higher.
ynh_check_app_version_changed() {
local return_value=${YNH_APP_UPGRADE_TYPE}

if [ "$return_value" == "UPGRADE_FULL" ] || [ "$return_value" == "UPGRADE_FORCED" ] || [ "$return_value" == "DOWNGRADE_FORCED" ]; then
if [ "$return_value" == "UPGRADE_SAME" ] || [ "$return_value" == "DOWNGRADE" ]; then
return_value="UPGRADE_APP"
fi

Expand Down
19 changes: 7 additions & 12 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,23 +653,18 @@ def app_upgrade(
manifest.get("remote", {}).get("revision", "?"),
)
continue
elif app_current_version > app_new_version:
upgrade_type = "DOWNGRADE_FORCED"

if app_current_version > app_new_version:
upgrade_type = "DOWNGRADE"
elif app_current_version == app_new_version:
upgrade_type = "UPGRADE_FORCED"
upgrade_type = "UPGRADE_SAME"
else:
app_current_version_upstream, app_current_version_pkg = str(
app_current_version
).split("~ynh")
app_new_version_upstream, app_new_version_pkg = str(
app_new_version
).split("~ynh")
app_current_version_upstream, _ = str(app_current_version).split("~ynh")
app_new_version_upstream, _ = str(app_new_version).split("~ynh")
if app_current_version_upstream == app_new_version_upstream:
upgrade_type = "UPGRADE_PACKAGE"
elif app_current_version_pkg == app_new_version_pkg:
upgrade_type = "UPGRADE_APP"
else:
upgrade_type = "UPGRADE_FULL"
upgrade_type = "UPGRADE_APP"

# Check requirements
for name, passed, values, err in _check_manifest_requirements(
Expand Down