Skip to content

Commit

Permalink
fix(service): fix cache not getting refreshed (#3657)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Nov 21, 2023
1 parent c1be009 commit 130c21d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions renku/ui/service/gateways/repository_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 130c21d

Please sign in to comment.