diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /app/services/projects/lfs_pointers/lfs_object_download_list_service.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'app/services/projects/lfs_pointers/lfs_object_download_list_service.rb')
-rw-r--r-- | app/services/projects/lfs_pointers/lfs_object_download_list_service.rb | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/app/services/projects/lfs_pointers/lfs_object_download_list_service.rb b/app/services/projects/lfs_pointers/lfs_object_download_list_service.rb index b4872cd9442..09fec9939b9 100644 --- a/app/services/projects/lfs_pointers/lfs_object_download_list_service.rb +++ b/app/services/projects/lfs_pointers/lfs_object_download_list_service.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -# This service manages the whole worflow of discovering the Lfs files in a -# repository, linking them to the project and downloading (and linking) the non -# existent ones. +# This service discovers the Lfs files that are linked in repository, +# but not downloaded yet and yields the operation +# on each Lfs file link (url) to remote repository. module Projects module LfsPointers class LfsObjectDownloadListService < BaseService @@ -14,30 +14,31 @@ module Projects LfsObjectDownloadListError = Class.new(StandardError) - 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 + def each_list_item(&block) + return unless context_valid? # Downloading the required information and gathering it inside an # LfsDownloadObject for each oid - # LfsDownloadLinkListService .new(project, remote_uri: current_endpoint_uri) - .execute(missing_lfs_files) + .each_link(missing_lfs_files, &block) rescue LfsDownloadLinkListService::DownloadLinksError => e raise LfsObjectDownloadListError, "The LFS objects download list couldn't be imported. Error: #{e.message}" end private + def context_valid? + return false unless project&.lfs_enabled? + return true unless 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! + false + end + def external_lfs_endpoint? lfsconfig_endpoint_uri && lfsconfig_endpoint_uri.host != import_uri.host end @@ -99,12 +100,10 @@ module Projects # The import url must end with '.git' here we ensure it is def default_endpoint_uri - @default_endpoint_uri ||= begin - import_uri.dup.tap do |uri| - path = uri.path.gsub(%r(/$), '') - path += '.git' unless path.ends_with?('.git') - uri.path = path + LFS_BATCH_API_ENDPOINT - end + @default_endpoint_uri ||= import_uri.dup.tap do |uri| + path = uri.path.gsub(%r(/$), '') + path += '.git' unless path.ends_with?('.git') + uri.path = path + LFS_BATCH_API_ENDPOINT end end end |