file-source: ensure over size limit files never do any content fetching when viewing the files.
- otherwise we use lot of memory - we can easily hit msgpack 4gb size limit on svn repos which often store such non binary files
This commit is contained in:
parent
38b8c11ea5
commit
5ef518bfdb
2 changed files with 48 additions and 32 deletions
|
|
@ -668,7 +668,10 @@ class RepoFilesView(RepoAppView):
|
|||
|
||||
c.file_source_page = 'true'
|
||||
c.file_last_commit = c.file.last_commit
|
||||
if c.file.size < c.visual.cut_off_limit_diff:
|
||||
|
||||
c.file_size_too_big = c.file.size > c.visual.cut_off_limit_file
|
||||
|
||||
if not c.file_size_too_big:
|
||||
if c.annotate: # annotation has precedence over renderer
|
||||
c.annotated_lines = filenode_as_annotated_lines_tokens(
|
||||
c.file
|
||||
|
|
|
|||
|
|
@ -60,14 +60,28 @@
|
|||
<div class="file-stats">
|
||||
|
||||
<div class="stats-info">
|
||||
<span class="stats-first-item">${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}</span>
|
||||
<span class="stats-first-item">
|
||||
% if c.file_size_too_big:
|
||||
0 ${(_('lines'))}
|
||||
% else:
|
||||
${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}
|
||||
% endif
|
||||
</span>
|
||||
|
||||
<span> | ${h.format_byte_size_binary(c.file.size)}</span>
|
||||
% if c.lf_node:
|
||||
<span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span>
|
||||
% endif
|
||||
<span> | ${c.file.mimetype} </span>
|
||||
<span> | ${h.get_lexer_for_filenode(c.file).__class__.__name__}</span>
|
||||
<span>
|
||||
| ${c.file.mimetype}
|
||||
</span>
|
||||
|
||||
% if not c.file_size_too_big:
|
||||
<span> |
|
||||
${h.get_lexer_for_filenode(c.file).__class__.__name__}
|
||||
</span>
|
||||
% endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -94,46 +108,45 @@
|
|||
</div>
|
||||
|
||||
<div class="code-body clear-fix ">
|
||||
|
||||
%if c.file.is_binary:
|
||||
<% rendered_binary = h.render_binary(c.repo_name, c.file)%>
|
||||
% if rendered_binary:
|
||||
${rendered_binary}
|
||||
% else:
|
||||
<div>
|
||||
${_('Binary file (%s)') % c.file.mimetype}
|
||||
${_('Binary file ({})').format(c.file.mimetype)}
|
||||
</div>
|
||||
% endif
|
||||
%else:
|
||||
% if c.file.size < c.visual.cut_off_limit_file:
|
||||
%if c.renderer and not c.annotate:
|
||||
## pick relative url based on renderer
|
||||
<%
|
||||
relative_urls = {
|
||||
'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
|
||||
'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
|
||||
}
|
||||
%>
|
||||
${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)}
|
||||
%else:
|
||||
<table class="cb codehilite">
|
||||
%if c.annotate:
|
||||
<% color_hasher = h.color_hasher() %>
|
||||
%for annotation, lines in c.annotated_lines:
|
||||
${sourceblock.render_annotation_lines(annotation, lines, color_hasher)}
|
||||
%endfor
|
||||
% if c.file_size_too_big:
|
||||
${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'),
|
||||
h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
|
||||
% else:
|
||||
%if c.renderer and not c.annotate:
|
||||
## pick relative url based on renderer
|
||||
<%
|
||||
relative_urls = {
|
||||
'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
|
||||
'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
|
||||
}
|
||||
%>
|
||||
${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)}
|
||||
%else:
|
||||
%for line_num, tokens in enumerate(c.lines, 1):
|
||||
${sourceblock.render_line(line_num, tokens)}
|
||||
%endfor
|
||||
<table class="cb codehilite">
|
||||
%if c.annotate:
|
||||
<% color_hasher = h.color_hasher() %>
|
||||
%for annotation, lines in c.annotated_lines:
|
||||
${sourceblock.render_annotation_lines(annotation, lines, color_hasher)}
|
||||
%endfor
|
||||
%else:
|
||||
%for line_num, tokens in enumerate(c.lines, 1):
|
||||
${sourceblock.render_line(line_num, tokens)}
|
||||
%endfor
|
||||
%endif
|
||||
</table>
|
||||
%endif
|
||||
</table>
|
||||
%endif
|
||||
%else:
|
||||
${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'),
|
||||
h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
|
||||
% endif
|
||||
%endif
|
||||
%endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue