summaryrefslogtreecommitdiff
path: root/app/models/blob_viewer
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-04-26 15:48:49 -0500
committerDouwe Maan <douwe@selenight.nl>2017-04-27 12:23:27 -0500
commit87a3bd26fa1c6379801062fd65fea59e587baeee (patch)
tree0376d4fcf33aa230bff1f686710fc97e20363450 /app/models/blob_viewer
parentc6b2a22f63bc7561beb3e596b14c62021d64c6e7 (diff)
downloadgitlab-ce-87a3bd26fa1c6379801062fd65fea59e587baeee.tar.gz
Address feedback
Diffstat (limited to 'app/models/blob_viewer')
-rw-r--r--app/models/blob_viewer/base.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/app/models/blob_viewer/base.rb b/app/models/blob_viewer/base.rb
index ab89429d07d..3ca73565d81 100644
--- a/app/models/blob_viewer/base.rb
+++ b/app/models/blob_viewer/base.rb
@@ -67,15 +67,18 @@ module BlobViewer
# binary from `blob_raw_url` and does its own format validation and error
# rendering, especially for potentially large binary formats.
def render_error
- if server_side_but_stored_in_lfs?
- # Files stored in LFS can only be rendered using a client-side viewer,
- # since we do not want to read large amounts of data into memory on the
- # server side. Client-side viewers use JS and can fetch the file from
- # `blob_raw_url` using AJAX.
- :server_side_but_stored_in_lfs
- elsif override_max_size ? absolutely_too_large? : too_large?
- :too_large
- end
+ return @render_error if defined?(@render_error)
+
+ @render_error =
+ if server_side_but_stored_in_lfs?
+ # Files stored in LFS can only be rendered using a client-side viewer,
+ # since we do not want to read large amounts of data into memory on the
+ # server side. Client-side viewers use JS and can fetch the file from
+ # `blob_raw_url` using AJAX.
+ :server_side_but_stored_in_lfs
+ elsif override_max_size ? absolutely_too_large? : too_large?
+ :too_large
+ end
end
def prepare!