Commit cb3173e1 authored by Mike Kozono's avatar Mike Kozono

Refactor: Remove requirement for local? method

For DRYness. And it removes a tiny bit of required work from the
framework doc.

I was going to write a centralized `local?` method somewhere but
discovered that all `Uploader` classes include `ObjectStorage::Concern`
which implements `file_storage?`, which is an equivalent check to these
`local?` methods.

The `local?` methods are more direct than going through
`replicator.carrierwave_uploader`, but this change is safe because we
already depend on `replicator.carrierwave_uploader` in the
`checksummable?` method.
parent 239771f5
...@@ -55,10 +55,6 @@ class Packages::PackageFile < ApplicationRecord ...@@ -55,10 +55,6 @@ class Packages::PackageFile < ApplicationRecord
Gitlab::Routing.url_helpers.download_project_package_file_path(project, self) Gitlab::Routing.url_helpers.download_project_package_file_path(project, self)
end end
def local?
file_store == ::Packages::PackageFileUploader::Store::LOCAL
end
private private
def update_size_from_file def update_size_from_file
......
...@@ -17,10 +17,6 @@ module Terraform ...@@ -17,10 +17,6 @@ module Terraform
mount_file_store_uploader StateUploader mount_file_store_uploader StateUploader
delegate :project_id, :uuid, to: :terraform_state, allow_nil: true delegate :project_id, :uuid, to: :terraform_state, allow_nil: true
def local?
file_store == ObjectStorage::Store::LOCAL
end
end end
end end
......
...@@ -189,11 +189,6 @@ For example, to add support for files referenced by a `Widget` model with a ...@@ -189,11 +189,6 @@ For example, to add support for files referenced by a `Widget` model with a
mount_uploader :file, WidgetUploader mount_uploader :file, WidgetUploader
def local?
# Must to be implemented, Check the uploader's storage types
file_store == ObjectStorage::Store::LOCAL
end
# @param primary_key_in [Range, Widget] arg to pass to primary_key_in scope # @param primary_key_in [Range, Widget] arg to pass to primary_key_in scope
# @return [ActiveRecord::Relation<Widget>] everything that should be synced to this node, restricted by primary key # @return [ActiveRecord::Relation<Widget>] everything that should be synced to this node, restricted by primary key
def self.replicables_for_current_secondary(primary_key_in) def self.replicables_for_current_secondary(primary_key_in)
......
...@@ -59,8 +59,8 @@ module EE ...@@ -59,8 +59,8 @@ module EE
super || build_merge_request_diff_detail super || build_merge_request_diff_detail
end end
def local? def checksummable?
stored_externally? && external_diff_store == ExternalDiffUploader::Store::LOCAL stored_externally? && super
end end
def log_geo_deleted_event def log_geo_deleted_event
......
...@@ -72,14 +72,14 @@ module Gitlab ...@@ -72,14 +72,14 @@ module Gitlab
# #
# @return [Boolean] whether it can generate a checksum # @return [Boolean] whether it can generate a checksum
def checksummable? def checksummable?
local? && file_exist? replicator.carrierwave_uploader.file_storage? && file_exist?
end end
# This checks for existence of the file on storage # This checks for existence of the file on storage
# #
# @return [Boolean] whether the file exists on storage # @return [Boolean] whether the file exists on storage
def file_exist? def file_exist?
if local? if replicator.carrierwave_uploader.file_storage?
File.exist?(replicator.carrierwave_uploader.path) File.exist?(replicator.carrierwave_uploader.path)
else else
replicator.carrierwave_uploader.exists? replicator.carrierwave_uploader.exists?
......
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