File: relation_export_upload.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (32 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module Projects
  module ImportExport
    class RelationExportUpload < ApplicationRecord
      include WithUploads

      self.table_name = 'project_relation_export_uploads'

      belongs_to :relation_export,
        class_name: 'Projects::ImportExport::RelationExport',
        foreign_key: :project_relation_export_id,
        inverse_of: :upload

      scope :for_project_export_jobs, ->(export_job_ids) do
        joins(:relation_export).where(
          relation_export: { project_export_job_id: export_job_ids }
        )
      end

      mount_uploader :export_file, ImportExportUploader

      # This causes CarrierWave v1 and v3 (but not v2) to upload the file to
      # object storage *after* the database entry has been committed to the
      # database. This avoids idling in a transaction. Similar to `ImportExportUpload`.
      if Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_STORE_EXPORT_FILE_AFTER_COMMIT', true))
        skip_callback :save, :after, :store_export_file!
        set_callback :commit, :after, :store_export_file!
      end
    end
  end
end