Module: ObjectStorage::BackgroundMove

Extended by:
ActiveSupport::Concern
Included in:
Appearance, Ci::Build, Ci::JobArtifact, ImportExportUpload, LfsObject, MergeRequestDiff
Defined in:
app/uploaders/object_storage.rb

Overview

Add support for automatic background uploading after the file is stored.

Instance Method Summary collapse

Instance Method Details

#background_upload(mount_points = []) ⇒ Object


105
106
107
108
109
110
111
# File 'app/uploaders/object_storage.rb', line 105

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

#changed_mountsObject


113
114
115
116
117
118
119
120
121
122
123
124
# File 'app/uploaders/object_storage.rb', line 113

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