diff options
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/ci/secure_file_uploader.rb | 4 | ||||
-rw-r--r-- | app/uploaders/file_mover.rb | 1 | ||||
-rw-r--r-- | app/uploaders/file_uploader.rb | 4 | ||||
-rw-r--r-- | app/uploaders/gitlab_uploader.rb | 13 | ||||
-rw-r--r-- | app/uploaders/object_storage.rb | 63 | ||||
-rw-r--r-- | app/uploaders/packages/composer/cache_uploader.rb | 2 | ||||
-rw-r--r-- | app/uploaders/packages/debian/component_file_uploader.rb | 2 | ||||
-rw-r--r-- | app/uploaders/packages/debian/distribution_release_file_uploader.rb | 2 | ||||
-rw-r--r-- | app/uploaders/packages/package_file_uploader.rb | 2 | ||||
-rw-r--r-- | app/uploaders/packages/rpm/repository_file_uploader.rb | 2 | ||||
-rw-r--r-- | app/uploaders/pages/deployment_uploader.rb | 7 | ||||
-rw-r--r-- | app/uploaders/terraform/state_uploader.rb | 4 |
12 files changed, 11 insertions, 95 deletions
diff --git a/app/uploaders/ci/secure_file_uploader.rb b/app/uploaders/ci/secure_file_uploader.rb index 8aa624d6b30..11cbfc6c1f2 100644 --- a/app/uploaders/ci/secure_file_uploader.rb +++ b/app/uploaders/ci/secure_file_uploader.rb @@ -34,10 +34,6 @@ module Ci false end - def background_upload_enabled? - false - end - def default_store object_store_enabled? ? ObjectStorage::Store::REMOTE : ObjectStorage::Store::LOCAL end diff --git a/app/uploaders/file_mover.rb b/app/uploaders/file_mover.rb index 95bc2680ed6..92ab2d88b41 100644 --- a/app/uploaders/file_mover.rb +++ b/app/uploaders/file_mover.rb @@ -24,7 +24,6 @@ class FileMover if update_markdown update_upload_model - uploader.schedule_background_upload end end diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 7250ce5c0b0..f947f70985c 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -27,10 +27,6 @@ class FileUploader < GitlabUploader after :remove, :prune_store_dir - # FileUploader do not run in a model transaction, so we can simply - # enqueue a job after the :store hook. - after :store, :schedule_background_upload - def self.root File.join(options.storage_path, 'uploads') end diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb index abe06bd97e1..62024bff4c0 100644 --- a/app/uploaders/gitlab_uploader.rb +++ b/app/uploaders/gitlab_uploader.rb @@ -101,8 +101,8 @@ class GitlabUploader < CarrierWave::Uploader::Base stream = if file_storage? File.open(path, "rb") if path - else - ::Gitlab::HttpIO.new(url, cached_size) if url + elsif url + ::Gitlab::HttpIO.new(url, cached_size) end return unless stream @@ -115,6 +115,15 @@ class GitlabUploader < CarrierWave::Uploader::Base end end + def multi_read(offsets) + open do |stream| + offsets.map do |start_offset, end_offset| + stream.seek(start_offset) + stream.read(end_offset - start_offset + 1) + end + end + end + # Used to replace an existing upload with another +file+ without modifying stored metadata # Use this method only to repair/replace an existing upload, or to upload to a Geo secondary node # diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb index 063aca7937c..e74998ce4a8 100644 --- a/app/uploaders/object_storage.rb +++ b/app/uploaders/object_storage.rb @@ -67,16 +67,6 @@ module ObjectStorage super end - def schedule_background_upload(*args) - return unless schedule_background_upload? - return unless upload - - ObjectStorage::BackgroundMoveWorker.perform_async(self.class.name, - upload.class.to_s, - mounted_as, - upload.id) - end - def exclusive_lease_key # For FileUploaders, model may have many uploaders. In that case # we want to use exclusive key per upload, not per model to allow @@ -99,40 +89,6 @@ module ObjectStorage end end - # Add support for automatic background uploading after the file is stored. - # - module BackgroundMove - extend ActiveSupport::Concern - - def background_upload(mount_points = []) - return unless mount_points.any? - - run_after_commit do - mount_points.each { |mount| send(mount).schedule_background_upload } # rubocop:disable GitlabSecurity/PublicSend - end - end - - def changed_mounts - self.class.uploaders.select do |mount, uploader_class| - mounted_as = uploader_class.serialization_column(self.class, mount) - uploader = send(:"#{mounted_as}") # rubocop:disable GitlabSecurity/PublicSend - - next unless uploader - next unless uploader.exists? - next unless send(:"saved_change_to_#{mounted_as}?") # rubocop:disable GitlabSecurity/PublicSend - - mount - end.keys - end - - included do - include AfterCommitQueue - after_save do - background_upload(changed_mounts) - end - end - end - module Concern extend ActiveSupport::Concern @@ -155,10 +111,6 @@ module ObjectStorage object_store_options&.direct_upload end - def background_upload_enabled? - object_store_options.background_upload - end - def proxy_download_enabled? object_store_options.proxy_download end @@ -311,15 +263,6 @@ module ObjectStorage end end - def schedule_background_upload(*args) - return unless schedule_background_upload? - - ObjectStorage::BackgroundMoveWorker.perform_async(self.class.name, - model.class.name, - mounted_as, - model.id) - end - def fog_directory self.class.remote_store_path end @@ -405,12 +348,6 @@ module ObjectStorage private - def schedule_background_upload? - self.class.object_store_enabled? && - self.class.background_upload_enabled? && - self.file_storage? - end - def cache_remote_file!(remote_object_id, original_filename) file_path = File.join(TMP_UPLOAD_PATH, remote_object_id) file_path = Pathname.new(file_path).cleanpath.to_s diff --git a/app/uploaders/packages/composer/cache_uploader.rb b/app/uploaders/packages/composer/cache_uploader.rb index f8052ec4810..ad7c017c4ba 100644 --- a/app/uploaders/packages/composer/cache_uploader.rb +++ b/app/uploaders/packages/composer/cache_uploader.rb @@ -4,8 +4,6 @@ class Packages::Composer::CacheUploader < GitlabUploader storage_options Gitlab.config.packages - after :store, :schedule_background_upload - alias_method :upload, :model def filename diff --git a/app/uploaders/packages/debian/component_file_uploader.rb b/app/uploaders/packages/debian/component_file_uploader.rb index e4d637fecac..2de4743d7f7 100644 --- a/app/uploaders/packages/debian/component_file_uploader.rb +++ b/app/uploaders/packages/debian/component_file_uploader.rb @@ -5,8 +5,6 @@ class Packages::Debian::ComponentFileUploader < GitlabUploader storage_options Gitlab.config.packages - after :store, :schedule_background_upload - alias_method :upload, :model def filename diff --git a/app/uploaders/packages/debian/distribution_release_file_uploader.rb b/app/uploaders/packages/debian/distribution_release_file_uploader.rb index a6ff3767b22..268d42796e9 100644 --- a/app/uploaders/packages/debian/distribution_release_file_uploader.rb +++ b/app/uploaders/packages/debian/distribution_release_file_uploader.rb @@ -5,8 +5,6 @@ class Packages::Debian::DistributionReleaseFileUploader < GitlabUploader storage_options Gitlab.config.packages - after :store, :schedule_background_upload - alias_method :upload, :model def filename diff --git a/app/uploaders/packages/package_file_uploader.rb b/app/uploaders/packages/package_file_uploader.rb index 9c0a88c9bf8..c8a09c50dc6 100644 --- a/app/uploaders/packages/package_file_uploader.rb +++ b/app/uploaders/packages/package_file_uploader.rb @@ -5,8 +5,6 @@ class Packages::PackageFileUploader < GitlabUploader storage_options Gitlab.config.packages - after :store, :schedule_background_upload - alias_method :upload, :model def filename diff --git a/app/uploaders/packages/rpm/repository_file_uploader.rb b/app/uploaders/packages/rpm/repository_file_uploader.rb index ff7e2bc719a..f95f861585c 100644 --- a/app/uploaders/packages/rpm/repository_file_uploader.rb +++ b/app/uploaders/packages/rpm/repository_file_uploader.rb @@ -6,8 +6,6 @@ module Packages storage_options Gitlab.config.packages - after :store, :schedule_background_upload - alias_method :upload, :model def filename diff --git a/app/uploaders/pages/deployment_uploader.rb b/app/uploaders/pages/deployment_uploader.rb index e510025fc7d..c5ba65673ab 100644 --- a/app/uploaders/pages/deployment_uploader.rb +++ b/app/uploaders/pages/deployment_uploader.rb @@ -36,13 +36,6 @@ module Pages false end - # we don't need background uploads because we upload files - # to the right store right away, and we already do that in - # the background job - def background_upload_enabled? - false - end - def default_store object_store_enabled? ? ObjectStorage::Store::REMOTE : ObjectStorage::Store::LOCAL end diff --git a/app/uploaders/terraform/state_uploader.rb b/app/uploaders/terraform/state_uploader.rb index 091b253b0ed..61e7ed7b0e6 100644 --- a/app/uploaders/terraform/state_uploader.rb +++ b/app/uploaders/terraform/state_uploader.rb @@ -48,10 +48,6 @@ module Terraform false end - def background_upload_enabled? - false - end - def proxy_download_enabled? true end |