Remove Gitlab::Geo::AvatarDownloader

parent 1683f020
......@@ -20,13 +20,10 @@ module Geo
private
def downloader
begin
klass = Gitlab::Geo.const_get("#{object_type.capitalize}Downloader")
klass.new(object_db_id)
rescue NameError
log("unknown file type: #{object_type}")
raise
end
klass = "Gitlab::Geo::#{object_type.to_s.camelize}Downloader".constantize
klass.new(object_db_id)
rescue NameError
Gitlab::Geo::FileDownloader.new(object_db_id)
end
def try_obtain_lease
......@@ -41,14 +38,12 @@ module Geo
end
end
def log(message)
Rails.logger.info "#{self.class.name}: #{message}"
end
def update_registry(bytes_downloaded)
transfer = Geo::FileRegistry.find_or_initialize_by(
file_type: object_type,
file_id: object_db_id)
file_id: object_db_id
)
transfer.bytes = bytes_downloaded
transfer.save
end
......
module Gitlab
module Geo
class AvatarDownloader < FileDownloader
def execute
upload = Upload.find_by_id(object_db_id)
return unless upload.present?
transfer = ::Gitlab::Geo::FileTransfer.new(:avatar, upload)
transfer.download_from_primary
end
end
end
end
......@@ -12,7 +12,11 @@ module Gitlab
# Subclasses should return the number of bytes downloaded,
# or nil or -1 if a failure occurred.
def execute
raise NotImplementedError
upload = Upload.find_by_id(object_db_id)
return unless upload.present?
transfer = ::Gitlab::Geo::FileTransfer.new(:avatar, upload)
transfer.download_from_primary
end
end
end
......
......@@ -3,7 +3,6 @@ module Gitlab
class LfsDownloader < FileDownloader
def execute
lfs_object = LfsObject.find_by_id(object_db_id)
return unless lfs_object.present?
transfer = ::Gitlab::Geo::LfsTransfer.new(lfs_object)
......
......@@ -72,8 +72,10 @@ describe Geo::FileDownloadService, services: true do
end
end
it 'raises an error with bad object type' do
expect{ described_class.new(:bad, 1).execute }.to raise_error(NameError)
context 'bad object type' do
it 'does not track transfer' do
expect{ described_class.new(:bad, 1).execute }.not_to change(Geo::FileRegistry, :count)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment