Properly fix version handling with packaging>=22.0

Both the current version and the last startup version can be unparsable.

Hence we now just catch the resulting exception and reset the version
to the new version, which may or may not be parsable, which we'll find
out on the next start up. But either way this prevents crashes from
unparsable versions in the database.
This commit is contained in:
Martin Weinelt 2023-05-29 16:03:47 +02:00
parent e313d4ef0d
commit 2a204988c3
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759

View File

@ -195,12 +195,14 @@ class MumbleBot:
th.start() th.start()
last_startup_version = var.db.get("bot", "version", fallback=None) last_startup_version = var.db.get("bot", "version", fallback=None)
if self.version != "git": try:
if not last_startup_version or version.parse(last_startup_version) < version.parse(self.version): if not last_startup_version or version.parse(last_startup_version) < version.parse(self.version):
var.db.set("bot", "version", self.version) var.db.set("bot", "version", self.version)
if var.config.getboolean("bot", "auto_check_update"): if var.config.getboolean("bot", "auto_check_update"):
changelog = util.fetch_changelog() changelog = util.fetch_changelog()
self.send_channel_msg(tr("update_successful", version=self.version, changelog=changelog)) self.send_channel_msg(tr("update_successful", version=self.version, changelog=changelog))
except version.InvalidVersion:
var.db.set("bot", "version", self.version)
# Set the CTRL+C shortcut # Set the CTRL+C shortcut
def ctrl_caught(self, signal, frame): def ctrl_caught(self, signal, frame):