##// 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 raise HTTPFound(
127 raise HTTPFound(
128 self.request.route_path('my_account_password'))
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 def _get_local_tmpl_context(self, include_app_defaults=False):
147 def _get_local_tmpl_context(self, include_app_defaults=False):
131 c = TemplateArgs()
148 c = TemplateArgs()
132 c.auth_user = self.request.user
149 c.auth_user = self.request.user
@@ -196,6 +213,7 b' class RepoAppView(BaseAppView):'
196 self.db_repo_name, error.message)
213 self.db_repo_name, error.message)
197
214
198 def _get_local_tmpl_context(self, include_app_defaults=False):
215 def _get_local_tmpl_context(self, include_app_defaults=False):
216 _ = self.request.translate
199 c = super(RepoAppView, self)._get_local_tmpl_context(
217 c = super(RepoAppView, self)._get_local_tmpl_context(
200 include_app_defaults=include_app_defaults)
218 include_app_defaults=include_app_defaults)
201
219
@@ -210,6 +228,17 b' class RepoAppView(BaseAppView):'
210 except RepositoryRequirementError as e:
228 except RepositoryRequirementError as e:
211 c.repository_requirements_missing = True
229 c.repository_requirements_missing = True
212 self._handle_missing_requirements(e)
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 return c
243 return c
215
244
@@ -26,7 +26,7 b' import pytest'
26 from rhodecode.apps.repository.views.repo_summary import RepoSummaryView
26 from rhodecode.apps.repository.views.repo_summary import RepoSummaryView
27 from rhodecode.lib import helpers as h
27 from rhodecode.lib import helpers as h
28 from rhodecode.lib.compat import OrderedDict
28 from rhodecode.lib.compat import OrderedDict
29 from rhodecode.lib.utils2 import AttributeDict
29 from rhodecode.lib.utils2 import AttributeDict, safe_str
30 from rhodecode.lib.vcs.exceptions import RepositoryRequirementError
30 from rhodecode.lib.vcs.exceptions import RepositoryRequirementError
31 from rhodecode.model.db import Repository
31 from rhodecode.model.db import Repository
32 from rhodecode.model.meta import Session
32 from rhodecode.model.meta import Session
@@ -259,7 +259,8 b' class TestSummaryView(object):'
259 class TestRepoLocation(object):
259 class TestRepoLocation(object):
260
260
261 @pytest.mark.parametrize("suffix", [u'', u'ąęł'], ids=['', 'non-ascii'])
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 repo = backend.create_repo(name_suffix=suffix)
264 repo = backend.create_repo(name_suffix=suffix)
264 repo_name = repo.repo_name
265 repo_name = repo.repo_name
265
266
@@ -272,13 +273,41 b' class TestRepoLocation(object):'
272
273
273 # check if repo is not in the filesystem
274 # check if repo is not in the filesystem
274 assert not repo_on_filesystem(repo_name)
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):
293 # test if the repo is still in the database
278 # run the check page that triggers the other flash message
294 new_repo = RepoModel().get_by_repo_name(repo_name)
279 response = self.app.get(h.url('repo_check_home', repo_name=repo_name))
295 assert new_repo.repo_name == repo_name
280 assert_session_flash(
296
281 response, 'The repository at %s cannot be located.' % repo_name)
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 @pytest.fixture()
313 @pytest.fixture()
General Comments 0
You need to be logged in to leave comments. Login now