diff options
| author | Douwe Maan <douwe@gitlab.com> | 2015-12-08 14:19:52 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2015-12-08 14:19:52 +0000 |
| commit | 51ed5225adf4aac3ccbf715f8647258dac784abb (patch) | |
| tree | 16137752ed3ea1ffd8c5398ceb131868dc2105d1 /app/controllers/projects | |
| parent | f5430e48b42227f1c1874ca27c6907f0f704be28 (diff) | |
| parent | 6245be083d985df3dd5daebb78ecf300bacff7b6 (diff) | |
| download | gitlab-ce-51ed5225adf4aac3ccbf715f8647258dac784abb.tar.gz | |
Merge branch 'serve_lfs_object' into 'master'
Serve LFS object
Depends on gitlab-org/gitlab_git!57
See merge request !1976
Diffstat (limited to 'app/controllers/projects')
| -rw-r--r-- | app/controllers/projects/raw_controller.rb | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index d5ee6ac8663..be7d5c187fe 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -10,15 +10,13 @@ class Projects::RawController < Projects::ApplicationController @blob = @repository.blob_at(@commit.id, @path) if @blob - type = get_blob_type - headers['X-Content-Type-Options'] = 'nosniff' - send_data( - @blob.data, - type: type, - disposition: 'inline' - ) + if @blob.lfs_pointer? + send_lfs_object + else + stream_data + end else render_404 end @@ -35,4 +33,33 @@ class Projects::RawController < Projects::ApplicationController 'application/octet-stream' end end + + def stream_data + type = get_blob_type + + send_data( + @blob.data, + type: type, + disposition: 'inline' + ) + end + + def send_lfs_object + lfs_object = find_lfs_object + + if lfs_object && lfs_object.project_allowed_access?(@project) + send_file lfs_object.file.path, filename: @blob.name, disposition: 'attachment' + else + render_404 + end + end + + def find_lfs_object + lfs_object = LfsObject.find_by_oid(@blob.lfs_oid) + if lfs_object && lfs_object.file.exists? + lfs_object + else + nil + end + end end |
