Class: Projects::LfsPointers::LfsDownloadLinkListService

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

Constant Summary collapse

DOWNLOAD_ACTION =
'download'
REQUEST_BATCH_SIZE =

This could be different per server, but it seems like a reasonable value to start with. github.com/git-lfs/git-lfs/issues/419

100
DownloadLinksError =
Class.new(StandardError)
DownloadLinkNotFound =
Class.new(StandardError)
DownloadLinksRequestEntityTooLargeError =
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, remote_uri: nil) ⇒ LfsDownloadLinkListService

Returns a new instance of LfsDownloadLinkListService.


20
21
22
23
24
# File 'app/services/projects/lfs_pointers/lfs_download_link_list_service.rb', line 20

def initialize(project, remote_uri: nil)
  super(project)

  @remote_uri = remote_uri
end

Instance Attribute Details

#remote_uriObject (readonly)

Returns the value of attribute remote_uri


18
19
20
# File 'app/services/projects/lfs_pointers/lfs_download_link_list_service.rb', line 18

def remote_uri
  @remote_uri
end

Instance Method Details

#execute(oids) ⇒ Object

This method accepts two parameters:

  • oids: hash of oids to query. The structure is { lfs_file_oid => lfs_file_size }

Returns an array of LfsDownloadObject


30
31
32
33
34
# File 'app/services/projects/lfs_pointers/lfs_download_link_list_service.rb', line 30

def execute(oids)
  return [] unless project&.lfs_enabled? && remote_uri && oids.present?

  get_download_links_in_batches(oids)
end