Fix has_recent_snapshot output without json

This commit is contained in:
Orsiris de Jong 2024-01-09 21:40:24 +01:00
parent b8c75b35d3
commit fca5343f52
2 changed files with 7 additions and 7 deletions

View file

@ -782,18 +782,16 @@ class NPBackupRunner:
)
# Temporarily disable verbose and enable json result
self.restic_runner.verbose = False
json_output = self.restic_runner.json_output
self.restic_runner.json_output = True
data = self.restic_runner.has_recent_snapshot(
self.minimum_backup_age
)
self.restic_runner.verbose = self.verbose
self.restic_runner.json_output = json_output
if self.json_output:
return data
result = data["result"]
backup_tz = data["output"]
# has_recent_snapshot returns a tuple when not self.json_output
result = data[0]
backup_tz = data[1]
if result:
self.write_logs(
f"Most recent backup in repo {self.repo_config.g('name')} is from {backup_tz}",

View file

@ -1074,8 +1074,10 @@ class ResticRunner:
return False, None
try:
# Make sure we run with json support for this one
json_output = self.json_output
self.json_output = True
result = self.snapshots()
self.json_output = json_output
if self.last_command_status is False:
if self.json_output:
msg = "Could not check for snapshots"