Skip to content

Commit

Permalink
fix: cannot cache last validated data, since it might change after up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
renatav committed Dec 4, 2024
1 parent 20a1142 commit 82bf67b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 11 additions & 13 deletions taf/auth_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class AuthenticationRepository(GitRepository, TAFRepository):

_conf_dir = None
_dependencies: Dict = {}
_last_validated_data: Optional[Dict] = None

def __init__(
self,
Expand Down Expand Up @@ -154,18 +153,17 @@ def last_validated_data(self) -> Optional[dict]:
"""
Return the last validated data of the authentication repository
"""
if self._last_validated_data is None:
last_validated_path = Path(self.conf_dir, self.LAST_VALIDATED_FILENAME)
self._last_validated_data = {}
if last_validated_path.is_file():
data = last_validated_path.read_text().strip()
try:
self._last_validated_data = json.loads(data)
except json.decoder.JSONDecodeError:
if data:
self._last_validated_data = {self.name: data}

return self._last_validated_data
last_validated_data = {}
last_validated_path = Path(self.conf_dir, self.LAST_VALIDATED_FILENAME)
if last_validated_path.is_file():
data = last_validated_path.read_text().strip()
try:
last_validated_data = json.loads(data)
except json.decoder.JSONDecodeError:
if data:
last_validated_data = {self.name: data}

return last_validated_data

@property
def log_prefix(self) -> str:
Expand Down
4 changes: 3 additions & 1 deletion taf/updater/updater_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ def _set_last_validated_commit(self):
# after a partial update, there is no need to validate the auth repo
# from an older commit, just because one of more targets were skipped
self.state.last_validated_data = users_auth_repo.last_validated_data
last_validated_commit = self.state.last_validated_data[users_auth_repo.name]
last_validated_commit = self.state.last_validated_data.get(
users_auth_repo.name
)

settings.last_validated_commit[
self.state.validation_auth_repo.name
Expand Down

0 comments on commit 82bf67b

Please sign in to comment.