error if X in last-X is too big

This commit is contained in:
manor-tile 2024-03-18 17:05:16 +01:00
parent f9d3ae1084
commit 45e3f6b1a2

View file

@ -173,15 +173,19 @@ def log_show(
share share
""" """
match_path = re.match(r"last(?:-(?P<position>[0-9]{1,6}))?$", path) # Set up path with correct value if 'last' or 'last-X' magic keywords are used
last = re.match(r"last(?:-(?P<position>[0-9]{1,6}))?$", path)
if match_path: if last:
if match_path.group("position") == None:
position = 1 position = 1
else: if last.group("position") is not None:
position = int(match_path.group("position")) + 1 position += int(last.group("position"))
logs = log_list()
path = list(logs["operation"])[-position]["path"] logs = list(log_list()["operation"])
if position > len(logs):
raise YunohostValidationError(f"There isn't that many logs", raw_msg=True)
path = logs[-position]["path"]
if share: if share:
filter_irrelevant = True filter_irrelevant = True