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)
ResponseError =
Class.new(StandardError)
LARGE_FILE_SIZE =
1.megabytes

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.



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_objectObject (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

#executeObject



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