Class: Projects::LfsPointers::LfsObjectDownloadListService

Inherits:
BaseService
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/projects/lfs_pointers/lfs_object_download_list_service.rb

Constant Summary collapse

HEAD_REV =
'HEAD'
LFS_ENDPOINT_PATTERN =
/^\t?url\s*=\s*(.+)$/.freeze
LFS_BATCH_API_ENDPOINT =
'/info/lfs/objects/batch'
LfsObjectDownloadListError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseService

#initialize

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

This class inherits a constructor from BaseService

Instance Method Details

#executeObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/projects/lfs_pointers/lfs_object_download_list_service.rb', line 17

def execute
  return [] unless project&.lfs_enabled?

  if external_lfs_endpoint?
    # If the endpoint host is different from the import_url it means
    # that the repo is using a third party service for storing the LFS files.
    # In this case, we have to disable lfs in the project
    disable_lfs!

    return []
  end

  # Downloading the required information and gathering it inside an
  #   LfsDownloadObject for each oid
  #
  LfsDownloadLinkListService
    .new(project, remote_uri: current_endpoint_uri)
    .execute(lfs_pointers_in_repository)
rescue LfsDownloadLinkListService::DownloadLinksError => e
  raise LfsObjectDownloadListError, "The LFS objects download list couldn't be imported. Error: #{e.message}"
end