##// END OF EJS Templates
repositories: handle in a nicer way a filesystem damaged repositories....
marcink -
r1984:cd3d1d07 default
parent child Browse files
Show More
@@ -127,6 +127,23 b' class BaseAppView(object):'
127 127 raise HTTPFound(
128 128 self.request.route_path('my_account_password'))
129 129
130 def _log_creation_exception(self, e, repo_name):
131 _ = self.request.translate
132 reason = None
133 if len(e.args) == 2:
134 reason = e.args[1]
135
136 if reason == 'INVALID_CERTIFICATE':
137 log.exception(
138 'Exception creating a repository: invalid certificate')
139 msg = (_('Error creating repository %s: invalid certificate')
140 % repo_name)
141 else:
142 log.exception("Exception creating a repository")
143 msg = (_('Error creating repository %s')
144 % repo_name)
145 return msg
146
130 147 def _get_local_tmpl_context(self, include_app_defaults=False):
131 148 c = TemplateArgs()
132 149 c.auth_user = self.request.user
@@ -196,6 +213,7 b' class RepoAppView(BaseAppView):'
196 213 self.db_repo_name, error.message)
197 214
198 215 def _get_local_tmpl_context(self, include_app_defaults=False):
216 _ = self.request.translate
199 217 c = super(RepoAppView, self)._get_local_tmpl_context(
200 218 include_app_defaults=include_app_defaults)
201 219
@@ -210,6 +228,17 b' class RepoAppView(BaseAppView):'
210 228 except RepositoryRequirementError as e:
211 229 c.repository_requirements_missing = True
212 230 self._handle_missing_requirements(e)
231 self.rhodecode_vcs_repo = None
232
233 if (not c.repository_requirements_missing
234 and self.rhodecode_vcs_repo is None):
235 # unable to fetch this repo as vcs instance, report back to user
236 h.flash(_(
237 "The repository `%(repo_name)s` cannot be loaded in filesystem. "
238 "Please check if it exist, or is not damaged.") %
239 {'repo_name': c.repo_name},
240 category='error', ignore_duplicate=True)
241 raise HTTPFound(h.route_path('home'))
213 242
214 243 return c
215 244
@@ -26,7 +26,7 b' import pytest'
26 26 from rhodecode.apps.repository.views.repo_summary import RepoSummaryView
27 27 from rhodecode.lib import helpers as h
28 28 from rhodecode.lib.compat import OrderedDict
29 from rhodecode.lib.utils2 import AttributeDict
29 from rhodecode.lib.utils2 import AttributeDict, safe_str
30 30 from rhodecode.lib.vcs.exceptions import RepositoryRequirementError
31 31 from rhodecode.model.db import Repository
32 32 from rhodecode.model.meta import Session
@@ -259,7 +259,8 b' class TestSummaryView(object):'
259 259 class TestRepoLocation(object):
260 260
261 261 @pytest.mark.parametrize("suffix", [u'', u'ąęł'], ids=['', 'non-ascii'])
262 def test_manual_delete(self, autologin_user, backend, suffix, csrf_token):
262 def test_missing_filesystem_repo(
263 self, autologin_user, backend, suffix, csrf_token):
263 264 repo = backend.create_repo(name_suffix=suffix)
264 265 repo_name = repo.repo_name
265 266
@@ -272,13 +273,41 b' class TestRepoLocation(object):'
272 273
273 274 # check if repo is not in the filesystem
274 275 assert not repo_on_filesystem(repo_name)
275 self.assert_repo_not_found_redirect(repo_name)
276
277 response = self.app.get(
278 route_path('repo_summary', repo_name=safe_str(repo_name)), status=302)
279
280 msg = 'The repository `%s` cannot be loaded in filesystem. ' \
281 'Please check if it exist, or is not damaged.' % repo_name
282 assert_session_flash(response, msg)
283
284 @pytest.mark.parametrize("suffix", [u'', u'ąęł'], ids=['', 'non-ascii'])
285 def test_missing_filesystem_repo_on_repo_check(
286 self, autologin_user, backend, suffix, csrf_token):
287 repo = backend.create_repo(name_suffix=suffix)
288 repo_name = repo.repo_name
289
290 # delete from file system
291 RepoModel()._delete_filesystem_repo(repo)
276 292
277 def assert_repo_not_found_redirect(self, repo_name):
278 # run the check page that triggers the other flash message
279 response = self.app.get(h.url('repo_check_home', repo_name=repo_name))
280 assert_session_flash(
281 response, 'The repository at %s cannot be located.' % repo_name)
293 # test if the repo is still in the database
294 new_repo = RepoModel().get_by_repo_name(repo_name)
295 assert new_repo.repo_name == repo_name
296
297 # check if repo is not in the filesystem
298 assert not repo_on_filesystem(repo_name)
299
300 # flush the session
301 self.app.get(
302 route_path('repo_summary', repo_name=safe_str(repo_name)),
303 status=302)
304
305 response = self.app.get(
306 route_path('repo_creating_check', repo_name=safe_str(repo_name)),
307 status=200)
308 msg = 'The repository `%s` cannot be loaded in filesystem. ' \
309 'Please check if it exist, or is not damaged.' % repo_name
310 assert_session_flash(response, msg )
282 311
283 312
284 313 @pytest.fixture()
General Comments 0
You need to be logged in to leave comments. Login now