Class: Projects::LfsPointers::LfsDownloadService
- Inherits:
-
BaseService
- Object
- BaseService
- Projects::LfsPointers::LfsDownloadService
- Defined in:
- app/services/projects/lfs_pointers/lfs_download_service.rb
Constant Summary collapse
- SizeError =
Class.new(StandardError)
- OidError =
Class.new(StandardError)
- ResponseError =
Class.new(StandardError)
- LARGE_FILE_SIZE =
1.megabytes
Instance Attribute Summary collapse
-
#lfs_download_object ⇒ Object
readonly
Returns the value of attribute lfs_download_object.
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, lfs_download_object) ⇒ LfsDownloadService
constructor
A new instance of LfsDownloadService.
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(project, lfs_download_object) ⇒ LfsDownloadService
Returns a new instance of LfsDownloadService.
17 18 19 20 21 |
# File 'app/services/projects/lfs_pointers/lfs_download_service.rb', line 17 def initialize(project, lfs_download_object) super(project) @lfs_download_object = lfs_download_object end |
Instance Attribute Details
#lfs_download_object ⇒ Object (readonly)
Returns the value of attribute lfs_download_object.
13 14 15 |
# File 'app/services/projects/lfs_pointers/lfs_download_service.rb', line 13 def lfs_download_object @lfs_download_object end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/services/projects/lfs_pointers/lfs_download_service.rb', line 23 def execute return unless project&.lfs_enabled? && lfs_download_object return error("LFS file with oid #{lfs_oid} has invalid attributes") unless lfs_download_object.valid? return link_existing_lfs_object! if Feature.enabled?(:lfs_link_existing_object, project) && lfs_size > LARGE_FILE_SIZE && lfs_object wrap_download_errors do download_lfs_file! end end |