Class: Projects::LfsPointers::LfsDownloadService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/projects/lfs_pointers/lfs_download_service.rb

Constant Summary collapse

SizeError =
Class.new(StandardError)
OidError =
Class.new(StandardError)

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

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

#can?

Constructor Details

#initialize(project, lfs_download_object) ⇒ LfsDownloadService

Returns a new instance of LfsDownloadService.


13
14
15
16
17
# File 'app/services/projects/lfs_pointers/lfs_download_service.rb', line 13

def initialize(project, lfs_download_object)
  super(project)

  @lfs_download_object = lfs_download_object
end

Instance Attribute Details

#lfs_download_objectObject (readonly)

Returns the value of attribute lfs_download_object


10
11
12
# File 'app/services/projects/lfs_pointers/lfs_download_service.rb', line 10

def lfs_download_object
  @lfs_download_object
end

Instance Method Details

#executeObject


19
20
21
22
23
24
25
26
# File 'app/services/projects/lfs_pointers/lfs_download_service.rb', line 19

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?

  wrap_download_errors do
    download_lfs_file!
  end
end