feat(caches): make sure commit-caches propagate to parent repo groups
This commit is contained in:
parent
fa3e6d2304
commit
7b14663e2c
3 changed files with 16 additions and 6 deletions
|
|
@ -207,7 +207,7 @@ def create_repo(form_data, cur_user):
|
|||
hooks_base.create_repository(created_by=owner.username, **repo.get_dict())
|
||||
|
||||
# update repo commit caches initially
|
||||
repo.update_commit_cache()
|
||||
repo.update_commit_cache(recursive=False)
|
||||
|
||||
# set new created state
|
||||
repo.set_state(Repository.STATE_CREATED)
|
||||
|
|
@ -298,7 +298,7 @@ def create_repo_fork(form_data, cur_user):
|
|||
# update repo commit caches initially
|
||||
config = repo._config
|
||||
config.set('extensions', 'largefiles', '')
|
||||
repo.update_commit_cache(config=config)
|
||||
repo.update_commit_cache(config=config, recursive=False)
|
||||
|
||||
# set new created state
|
||||
repo.set_state(Repository.STATE_CREATED)
|
||||
|
|
@ -390,7 +390,7 @@ def sync_last_update_for_objects(*args, **kwargs):
|
|||
.order_by(Repository.group_id.asc())
|
||||
|
||||
for repo in repos:
|
||||
repo.update_commit_cache()
|
||||
repo.update_commit_cache(recursive=False)
|
||||
|
||||
skip_groups = kwargs.get('skip_groups')
|
||||
if not skip_groups:
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ def repo2db_mapper(initial_repo_list, remove_obsolete=False, force_hooks_rebuild
|
|||
log.debug('Running update server info')
|
||||
git_repo._update_server_info(force=True)
|
||||
|
||||
db_repo.update_commit_cache()
|
||||
db_repo.update_commit_cache(recursive=False)
|
||||
|
||||
config = db_repo._config
|
||||
config.set('extensions', 'largefiles', '')
|
||||
|
|
|
|||
|
|
@ -2568,10 +2568,10 @@ class Repository(Base, BaseModel):
|
|||
return commit
|
||||
|
||||
def flush_commit_cache(self):
|
||||
self.update_commit_cache(cs_cache={'raw_id':'0'})
|
||||
self.update_commit_cache(cs_cache={'raw_id': '0'})
|
||||
self.update_commit_cache()
|
||||
|
||||
def update_commit_cache(self, cs_cache=None, config=None):
|
||||
def update_commit_cache(self, cs_cache=None, config=None, recursive=True):
|
||||
"""
|
||||
Update cache of last commit for repository
|
||||
cache_keys should be::
|
||||
|
|
@ -2610,6 +2610,14 @@ class Repository(Base, BaseModel):
|
|||
if isinstance(cs_cache, BaseCommit):
|
||||
cs_cache = cs_cache.__json__()
|
||||
|
||||
def maybe_update_recursive(instance, _config, _recursive, _cs_cache, _last_change):
|
||||
if _recursive:
|
||||
repo_id = instance.repo_id
|
||||
_cs_cache['source_repo_id'] = repo_id
|
||||
for gr in instance.groups_with_parents:
|
||||
gr.changeset_cache = _cs_cache
|
||||
gr.updated_on = _last_change
|
||||
|
||||
def is_outdated(new_cs_cache):
|
||||
if (new_cs_cache['raw_id'] != self.changeset_cache['raw_id'] or
|
||||
new_cs_cache['revision'] != self.changeset_cache['revision']):
|
||||
|
|
@ -2636,6 +2644,7 @@ class Repository(Base, BaseModel):
|
|||
self.changeset_cache = cs_cache
|
||||
self.updated_on = last_change
|
||||
Session().add(self)
|
||||
maybe_update_recursive(self, config, recursive, cs_cache, last_change)
|
||||
Session().commit()
|
||||
|
||||
else:
|
||||
|
|
@ -2650,6 +2659,7 @@ class Repository(Base, BaseModel):
|
|||
self.changeset_cache = cs_cache
|
||||
self.updated_on = _date_latest
|
||||
Session().add(self)
|
||||
maybe_update_recursive(self, config, recursive, cs_cache, _date_latest)
|
||||
Session().commit()
|
||||
|
||||
log.debug('updated repo `%s` with new commit cache %s, and last update_date: %s',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue