2014-08-13 14:28:22 -04:00
|
|
|
class ArchiveRepositoryService
|
2015-03-24 08:15:59 -04:00
|
|
|
attr_reader :project, :ref, :format
|
2014-08-13 14:28:22 -04:00
|
|
|
|
2015-03-24 08:15:59 -04:00
|
|
|
def initialize(project, ref, format)
|
|
|
|
format ||= 'tar.gz'
|
2015-03-24 08:24:35 -04:00
|
|
|
@project, @ref, @format = project, ref, format.downcase
|
2015-03-24 08:15:59 -04:00
|
|
|
end
|
|
|
|
|
2015-03-31 07:37:21 -04:00
|
|
|
def execute(options = {})
|
2015-10-16 12:39:17 -04:00
|
|
|
RepositoryArchiveCacheWorker.perform_async
|
2015-03-24 08:15:59 -04:00
|
|
|
|
2015-10-08 11:12:00 -04:00
|
|
|
metadata = project.repository.archive_metadata(ref, storage_path, format)
|
|
|
|
raise "Repository or ref not found" if metadata.empty?
|
2015-03-24 08:15:59 -04:00
|
|
|
|
2015-10-08 11:12:00 -04:00
|
|
|
metadata
|
2015-03-24 08:15:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def storage_path
|
|
|
|
Gitlab.config.gitlab.repository_downloads_path
|
|
|
|
end
|
2014-08-13 14:28:22 -04:00
|
|
|
end
|