From d02c7df75cfb1f38cf3c90ff03d98c0382a4df29 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 1 Apr 2022 15:31:10 -0700 Subject: [PATCH] json parse version string --- src/documents/views.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/documents/views.py b/src/documents/views.py index 09f18c9e6..858a3bab6 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -1,6 +1,6 @@ +import json import logging import os -import re import tempfile import urllib import uuid @@ -683,9 +683,11 @@ class RemoteVersionView(GenericAPIView): + "/paperless-ngx/main/src/paperless/version.py", ) as response: remote = response.read().decode("utf-8") - match = re.search(r"(\d+, \d+, \d+)", remote) - if match: - remote_version = ".".join(match[0].split(", ")) + try: + remote_json = json.loads(remote) + remote_version = remote_json["tag_name"].replace("ngx-", "") + except ValueError: + logger.debug("An error occured parsing remote version json") except urllib.error.URLError: logger.debug("An error occured checking for available updates")