Skip to content

Commit

Permalink
Merge pull request #3480 from jestabro/fix-circular
Browse files Browse the repository at this point in the history
T6354: do an explicit read from version file to avoid circular reference
  • Loading branch information
dmbaturin authored May 18, 2024
2 parents 807791a + e0105ef commit 4686ab7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/vyos/system/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
from functools import wraps
from tempfile import TemporaryDirectory
from typing import TypedDict
from json import loads

from vyos import version
from vyos.defaults import directories
from vyos.system import disk, grub

# Define variables
Expand Down Expand Up @@ -201,9 +202,12 @@ def get_running_image() -> str:
if running_image_result:
running_image: str = running_image_result.groupdict().get(
'image_version', '')
# we need to have a fallback for live systems
# we need to have a fallback for live systems:
# explicit read from version file
if not running_image:
running_image: str = version.get_version()
json_data: str = Path(directories['data']).joinpath('version.json').read_text()
dict_data: dict = loads(json_data)
running_image: str = dict_data['version']

return running_image

Expand Down

0 comments on commit 4686ab7

Please sign in to comment.