Skip to content
Open
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
28 changes: 28 additions & 0 deletions python/shotgun_desktop/upgrade_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ def _out_of_date_check(latest_descriptor, current_desc):
% current_desc.get_version(),
)
return False

# Test if app_store version is lower than the current version
try:
import packaging.version

current_version = packaging.version.parse(current_desc.get_version())
app_store_version = packaging.version.parse(latest_descriptor.get_version())
except ImportError:
logger.exception("Could not import packaging module")
except packaging.version.InvalidVersion:
logger.warning(
"Could not parse version(s) %s/%s",
current_desc.get_version(),
latest_descriptor.get_version(),
)
else:
if current_version <= app_store_version:
pass
elif os.environ.get("SGTK_STARTUP_ALLOW_OLDER_VERSION"):
pass
else:
logger.warning(
"Ignore app_store version %s since current version is newer %s",
latest_descriptor.version,
current_desc.get_version(),
)
return False
Comment on lines +75 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it but can it be rewritten like this?

Suggested change
if current_version <= app_store_version:
pass
elif os.environ.get("SGTK_STARTUP_ALLOW_OLDER_VERSION"):
pass
else:
logger.warning(
"Ignore app_store version %s since current version is newer %s",
latest_descriptor.version,
current_desc.get_version(),
)
return False
if os.environ.get("SGTK_STARTUP_ALLOW_OLDER_VERSION"):
pass
elif current_version > app_store_version:
logger.warning(
"Ignore app_store version %s since current version is newer %s",
latest_descriptor.version,
current_desc.get_version(),
)
return False

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think both are equivalent. I wrote it this way because that would be easy to add logs later if needed.
Also I find it easier to read but it's a personal preference.


return latest_descriptor.get_version() != current_desc.get_version()


Expand Down