klaus
klaus copied to clipboard
handle dulwich.objects.EmptyFileException
This one is pretty obscure, but Dulwich may raise EmptyFileException when part of the repository is corrupted. It would be nice if klaus displayed an appropriate error page.
File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 332, in make_template_context
super(IndexView, self).make_template_context(*args)
File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 222, in make_template_context
super(TreeViewMixin, self).make_template_context(*args)
File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 184, in make_template_context
repo, rev, path, commit = _get_repo_and_rev(repo, namespace, rev, path)
File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 111, in _get_repo_and_rev
rev = repo.get_default_branch()
File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 147, in get_default_branch
for name in self.get_branch_names():
File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 182, in get_branch_names
return self.get_ref_names_ordered_by_last_commit("refs/heads", exclude)
File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 175, in get_ref_names_ordered_by_last_commit
sorted_names = sorted(refs.keys(), key=get_commit_time, reverse=True)
File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 163, in get_commit_time
obj = self[refs[refname]]
File "/code/dulwich/dulwich/repo.py", line 783, in __getitem__
return self.object_store[name]
File "/code/dulwich/dulwich/object_store.py", line 144, in __getitem__
type_num, uncomp = self.get_raw(sha)
File "/code/dulwich/dulwich/object_store.py", line 581, in get_raw
ret = self._get_loose_object(hexsha)
File "/code/dulwich/dulwich/object_store.py", line 745, in _get_loose_object
return ShaFile.from_path(path)
File "/code/dulwich/dulwich/objects.py", line 422, in from_path
return cls.from_file(f)
File "/code/dulwich/dulwich/objects.py", line 428, in from_file
obj = cls._parse_file(f)
File "/code/dulwich/dulwich/objects.py", line 396, in _parse_file
raise EmptyFileException("Corrupted empty file detected")
dulwich.objects.EmptyFileException: Corrupted empty file detected </div>