Class: Gitlab::BackgroundMigration::LegacyUploadMover
- Inherits:
-
Object
- Object
- Gitlab::BackgroundMigration::LegacyUploadMover
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/background_migration/legacy_upload_mover.rb
Overview
This class takes a legacy upload and migrates it to the correct location
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#upload ⇒ Object
readonly
Returns the value of attribute upload.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(upload) ⇒ LegacyUploadMover
constructor
A new instance of LegacyUploadMover.
Constructor Details
#initialize(upload) ⇒ LegacyUploadMover
Returns a new instance of LegacyUploadMover.
12 13 14 15 16 17 |
# File 'lib/gitlab/background_migration/legacy_upload_mover.rb', line 12 def initialize(upload) @upload = upload @note = Note.find_by(id: upload.model_id) @project = note&.project @logger = Gitlab::BackgroundMigration::Logger.build end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
10 11 12 |
# File 'lib/gitlab/background_migration/legacy_upload_mover.rb', line 10 def logger @logger end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
9 10 11 |
# File 'lib/gitlab/background_migration/legacy_upload_mover.rb', line 9 def note @note end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
9 10 11 |
# File 'lib/gitlab/background_migration/legacy_upload_mover.rb', line 9 def project @project end |
#upload ⇒ Object (readonly)
Returns the value of attribute upload.
9 10 11 |
# File 'lib/gitlab/background_migration/legacy_upload_mover.rb', line 9 def upload @upload end |
Instance Method Details
#execute ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/background_migration/legacy_upload_mover.rb', line 19 def execute return unless upload return unless upload.model_type == 'Note' if !project # if we don't have models associated with the upload we can not move it warn('Deleting upload due to model not found.') destroy_legacy_upload elsif note.is_a?(LegacyDiffNote) return unless move_legacy_diff_file migrate_upload elsif !legacy_file_exists? warn('Deleting upload due to file not found.') destroy_legacy_upload else migrate_upload end end |