fix: prefer scm_revision as the cache_id if available

This commit is contained in:
Peter Braun
2026-07-30 13:43:47 +02:00
parent f1a3e13df7
commit 1ff6edc05d

View File

@@ -450,13 +450,14 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn
@property @property
def cache_id(self): def cache_id(self):
"""This gives the folder name where collections and roles will be saved to so it does not re-download # Prefer scm_revision as the cache key if available. This guarantees that project changes are tracked correctly
# even over multiple nodes. The scm_revision is a hex string and thus safe to be used as a directory name.
if self.scm_revision:
return self.scm_revision
Normally we want this to track with the last update, because every update should pull new content. # If no scm_revision is available (e.g. non-scm projects), use these. current_job_id and last_job_id are global
This does not count sync jobs, but sync jobs do not update last_job or current_job anyway. # IDs in the database. This means that when a project sync runs on one node, all other nodes become outdated,
If cleanup_jobs deletes the last jobs, then we can fallback to using any given heuristic related # resulting in unnecessary re-syncs.
to the last job ran.
"""
if self.current_job_id: if self.current_job_id:
return str(self.current_job_id) return str(self.current_job_id)
elif self.last_job_id: elif self.last_job_id: