From 74da491bd17d4317c5f277236b0f65be0f7acc87 Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Mon, 5 Apr 2021 22:09:55 +0800 Subject: [PATCH] Fix Installed badge won't display in release page --- bazarr/api.py | 8 ++++---- bazarr/main.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bazarr/api.py b/bazarr/api.py index 037548732..0fb02d8af 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -554,12 +554,11 @@ class SystemStatus(Resource): class SystemReleases(Resource): @authenticate def get(self): - releases = [] + filtered_releases = [] try: with io.open(os.path.join(args.config_dir, 'config', 'releases.txt'), 'r', encoding='UTF-8') as f: releases = json.loads(f.read()) - filtered_releases = [] for release in releases: if settings.general.branch == 'master' and not release['prerelease']: filtered_releases.append(release) @@ -570,14 +569,15 @@ class SystemReleases(Resource): if settings.general.branch == 'master': filtered_releases = filtered_releases[:5] + current_version = os.environ["BAZARR_VERSION"] + for i, release in enumerate(filtered_releases): body = release['body'].replace('- ', '').split('\n')[1:] filtered_releases[i] = {"body": body, "name": release['name'], "date": release['date'][:10], "prerelease": release['prerelease'], - "current": True if release['name'].lstrip('v') == os.environ["BAZARR_VERSION"] - else False} + "current": release['name'].lstrip('v') == current_version} except Exception as e: logging.exception( diff --git a/bazarr/main.py b/bazarr/main.py index 9549d1982..e16c8c113 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -2,12 +2,13 @@ import os -bazarr_version = '' +bazarr_version = 'unknown' version_file = os.path.join(os.path.dirname(__file__), '..', 'VERSION') if os.path.isfile(version_file): with open(version_file, 'r') as f: - bazarr_version = f.read() + bazarr_version = f.readline() + bazarr_version = bazarr_version.rstrip('\n') os.environ["BAZARR_VERSION"] = bazarr_version