File: 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 (26 lines) | stat: -rw-r--r-- 908 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
# frozen_string_literal: true

module BulkImports
  class ExportUpload < ApplicationRecord
    include WithUploads

    self.table_name = 'bulk_import_export_uploads'

    belongs_to :export, class_name: 'BulkImports::Export'
    belongs_to :batch, class_name: 'BulkImports::ExportBatch', optional: true

    mount_uploader :export_file, ExportUploader

    # 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

    def retrieve_upload(_identifier, paths)
      Upload.find_by(model: self, path: paths)
    end
  end
end