You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2022/06/02 20:27:58 UTC
[allura] branch master updated: [#8432] diffs - add max file size
This is an automated email from the ASF dual-hosted git repository.
gcruz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new 8d67f82d4 [#8432] diffs - add max file size
8d67f82d4 is described below
commit 8d67f82d45fcf5615a306d564ec68026e3c98654
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Wed May 25 18:12:51 2022 +0000
[#8432] diffs - add max file size
---
Allura/allura/controllers/repository.py | 16 +++++++++-------
Allura/development.ini | 3 +++
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 73d4eee96..9059526bf 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -919,6 +919,12 @@ class FileBrowser(BaseController):
if not self._blob.has_html_view:
diff = "Cannot display: file marked as a binary type."
return dict(a=a, b=b, diff=diff)
+
+ if max(a.size, b.size) > asint(tg.config.get('scm.view.max_diff_bytes', 2000000)):
+ # have to check the original file size, not diff size, because difflib._mdiff inside HtmlSideBySideDiff
+ # can take an extremely long time on large files (and its even a generator)
+ diff = 'File too large to view diff'
+ return dict(a=a, b=b, diff=diff)
# could consider making Blob.__iter__ do unicode conversion?
# py2 unified_diff can handle some unicode but not consistently, so best to do ensure_str (can drop it on py3)
@@ -932,14 +938,10 @@ class FileBrowser(BaseController):
else:
web_session['diformat'] = fmt
web_session.save()
+
if fmt == 'sidebyside':
- if max(a.size, b.size) > asint(tg.config.get('scm.view.max_syntax_highlight_bytes', 500000)):
- # have to check the original file size, not diff size, because difflib._mdiff inside HtmlSideBySideDiff
- # can take an extremely long time on large files (and its even a generator)
- diff = '<em>File too large for side-by-side view</em>'
- else:
- hd = HtmlSideBySideDiff()
- diff = hd.make_table(la, lb, adesc, bdesc)
+ hd = HtmlSideBySideDiff()
+ diff = hd.make_table(la, lb, adesc, bdesc)
else:
# py2 unified_diff can handle some unicode but not consistently, so best to do str() and ensure_str()
# (can drop it on py3)
diff --git a/Allura/development.ini b/Allura/development.ini
index d7ff83ebd..6bbfb8458 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -433,6 +433,9 @@ scm.view.max_syntax_highlight_bytes = 500000
; Max size for viewing a file from a repo, can take a lot of template processing (even with syntax highlighting disabled)
scm.view.max_file_bytes = 5000000
+; Default limit for when to stop performing a diff (both side-by-side and default)
+scm.view.max_diff_bytes = 2000000
+
; Max size for download a raw file from a repo
scm.download.max_file_bytes = 30000000