Show More
@@ -121,6 +121,7 b' class ScmModel(BaseModel):' | |||||
121 | all_repos = self.sa.query(Repository)\ |
|
121 | all_repos = self.sa.query(Repository)\ | |
122 | .order_by(Repository.repo_name).all() |
|
122 | .order_by(Repository.repo_name).all() | |
123 |
|
123 | |||
|
124 | #get the repositories that should be invalidated | |||
124 | invalidation_list = [str(x.cache_key) for x in \ |
|
125 | invalidation_list = [str(x.cache_key) for x in \ | |
125 | self.sa.query(CacheInvalidation.cache_key)\ |
|
126 | self.sa.query(CacheInvalidation.cache_key)\ | |
126 | .filter(CacheInvalidation.cache_active == False)\ |
|
127 | .filter(CacheInvalidation.cache_active == False)\ | |
@@ -158,13 +159,33 b' class ScmModel(BaseModel):' | |||||
158 | """ |
|
159 | """ | |
159 | Get's repository from given name, creates BackendInstance and |
|
160 | Get's repository from given name, creates BackendInstance and | |
160 | propagates it's data from database with all additional information |
|
161 | propagates it's data from database with all additional information | |
|
162 | ||||
161 | :param repo_name: |
|
163 | :param repo_name: | |
|
164 | :param invalidation_list: if a invalidation list is given the get | |||
|
165 | method should not manually check if this repository needs | |||
|
166 | invalidation and just invalidate the repositories in list | |||
|
167 | ||||
162 | """ |
|
168 | """ | |
163 | if not HasRepoPermissionAny('repository.read', 'repository.write', |
|
169 | if not HasRepoPermissionAny('repository.read', 'repository.write', | |
164 | 'repository.admin')(repo_name, 'get repo check'): |
|
170 | 'repository.admin')(repo_name, 'get repo check'): | |
165 | return |
|
171 | return | |
166 |
|
172 | |||
|
173 | pre_invalidate = True | |||
|
174 | if invalidation_list is not None: | |||
|
175 | pre_invalidate = repo_name in invalidation_list | |||
167 |
|
176 | |||
|
177 | if pre_invalidate: | |||
|
178 | invalidate = self._should_invalidate(repo_name) | |||
|
179 | ||||
|
180 | if invalidate: | |||
|
181 | log.info('invalidating cache for repository %s', repo_name) | |||
|
182 | region_invalidate(_get_repo, None, repo_name) | |||
|
183 | self._mark_invalidated(invalidate) | |||
|
184 | ||||
|
185 | ||||
|
186 | #====================================================================== | |||
|
187 | # CACHE FUNCTION | |||
|
188 | #====================================================================== | |||
168 | @cache_region('long_term') |
|
189 | @cache_region('long_term') | |
169 | def _get_repo(repo_name): |
|
190 | def _get_repo(repo_name): | |
170 |
|
191 | |||
@@ -203,18 +224,6 b' class ScmModel(BaseModel):' | |||||
203 | repo.dbrepo = dbrepo |
|
224 | repo.dbrepo = dbrepo | |
204 | return repo |
|
225 | return repo | |
205 |
|
226 | |||
206 | pre_invalidate = True |
|
|||
207 | if invalidation_list: |
|
|||
208 | pre_invalidate = repo_name in invalidation_list |
|
|||
209 |
|
||||
210 | if pre_invalidate: |
|
|||
211 | invalidate = self._should_invalidate(repo_name) |
|
|||
212 |
|
||||
213 | if invalidate: |
|
|||
214 | log.info('invalidating cache for repository %s', repo_name) |
|
|||
215 | region_invalidate(_get_repo, None, repo_name) |
|
|||
216 | self._mark_invalidated(invalidate) |
|
|||
217 |
|
||||
218 | return _get_repo(repo_name) |
|
227 | return _get_repo(repo_name) | |
219 |
|
228 | |||
220 |
|
229 |
General Comments 0
You need to be logged in to leave comments.
Login now