From 6b4fb43260069ad18f9181068fb8e0185e81da5b Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Tue, 21 Nov 2023 17:20:42 +0100 Subject: [PATCH] fix(service): fix cache not getting refreshed --- renku/ui/service/gateways/repository_cache.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/renku/ui/service/gateways/repository_cache.py b/renku/ui/service/gateways/repository_cache.py index c228a73ba7..1b39bb87eb 100644 --- a/renku/ui/service/gateways/repository_cache.py +++ b/renku/ui/service/gateways/repository_cache.py @@ -56,11 +56,17 @@ def get( """Get a project from cache (clone if necessary).""" if git_url is None: raise ValidationError("Invalid `git_url`, URL is empty", "git_url") + # Note: walrus turns None into empty strings + branch = branch or "" + commit_sha = commit_sha or "" git_url = normalize_git_url(git_url) try: project = Project.get( - (Project.user_id == user.user_id) & (Project.git_url == git_url) & (Project.branch == branch) + (Project.user_id == user.user_id) + & (Project.git_url == git_url) + & (Project.branch == branch) + & (Project.commit_sha == commit_sha) ) except ValueError: # project not found in DB @@ -225,7 +231,7 @@ def _maybe_update_cache(self, project: Project, user: User): if project.fetch_age < PROJECT_FETCH_TIME: return - if project.commit_sha is not None: + if project.commit_sha is not None and project.commit_sha != "": # NOTE: A project in a detached head state at a specific commit SHA cannot be updated return