Prevent 500 error on Compare page if diff read timout happens

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-02-05 16:21:41 +02:00
parent 8f88cbf06b
commit a1a01254b9
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
2 changed files with 12 additions and 3 deletions

View File

@ -16,6 +16,11 @@ class Projects::CompareController < Projects::ApplicationController
@refs_are_same = compare.same
@line_notes = []
if @diffs == [Gitlab::Git::Diff::BROKEN_DIFF]
@diffs = []
@timeout = true
end
diff_line_count = Commit::diff_line_count(@diffs)
@suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff]
@force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count)

View File

@ -22,10 +22,14 @@
- if @diffs.present?
= render "projects/commits/diffs", diffs: @diffs, project: @project
- elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
.alert.alert-warning
%p
%strong Warning! This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits.
.bs-callout.bs-callout-danger
%h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits.
%p To preserve performance the line diff is not shown.
- elsif @timeout
.bs-callout.bs-callout-danger
%h4 Diff for this comparison is extremely large.
%p Use command line to browse diff for this comparison.
- else
.light-well