diff options
Diffstat (limited to 'app/models/blob_viewer/server_side.rb')
-rw-r--r-- | app/models/blob_viewer/server_side.rb | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/app/models/blob_viewer/server_side.rb b/app/models/blob_viewer/server_side.rb index 899107d02ea..05a3dd7d913 100644 --- a/app/models/blob_viewer/server_side.rb +++ b/app/models/blob_viewer/server_side.rb @@ -3,9 +3,28 @@ module BlobViewer extend ActiveSupport::Concern included do - self.client_side = false - self.max_size = 2.megabytes - self.absolute_max_size = 5.megabytes + self.load_async = true + self.collapse_limit = 2.megabytes + self.size_limit = 5.megabytes + end + + def prepare! + if blob.project + blob.load_all_data!(blob.project.repository) + end + end + + def render_error + if blob.stored_externally? + # Files that are not stored in the repository, like LFS files and + # build artifacts, 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. + return :server_side_but_stored_externally + end + + super end end end |