Pass object type to the file downloader

parent eaf0a841
...@@ -21,9 +21,9 @@ module Geo ...@@ -21,9 +21,9 @@ module Geo
def downloader def downloader
klass = "Gitlab::Geo::#{object_type.to_s.camelize}Downloader".constantize klass = "Gitlab::Geo::#{object_type.to_s.camelize}Downloader".constantize
klass.new(object_db_id) klass.new(object_type, object_db_id)
rescue NameError rescue NameError
Gitlab::Geo::FileDownloader.new(object_db_id) Gitlab::Geo::FileDownloader.new(object_type, object_db_id)
end end
def try_obtain_lease def try_obtain_lease
......
module Gitlab module Gitlab
module Geo module Geo
class FileDownloader class FileDownloader
attr_reader :object_db_id attr_reader :object_type, :object_db_id
def initialize(object_db_id) def initialize(object_type, object_db_id)
@object_type = object_type
@object_db_id = object_db_id @object_db_id = object_db_id
end end
...@@ -15,7 +16,7 @@ module Gitlab ...@@ -15,7 +16,7 @@ module Gitlab
upload = Upload.find_by_id(object_db_id) upload = Upload.find_by_id(object_db_id)
return unless upload.present? return unless upload.present?
transfer = ::Gitlab::Geo::FileTransfer.new(:avatar, upload) transfer = ::Gitlab::Geo::FileTransfer.new(object_type.to_sym, upload)
transfer.download_from_primary transfer.download_from_primary
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