Class: Projects::HashedStorage::MigrateAttachmentsService
- Inherits:
-
BaseAttachmentService
- Object
- BaseService
- BaseAttachmentService
- Projects::HashedStorage::MigrateAttachmentsService
- Extended by:
- Gitlab::Utils::Override
- Defined in:
- app/services/projects/hashed_storage/migrate_attachments_service.rb
Constant Summary collapse
- DISCARDABLE_PATHS =
List of paths that can be excluded while evaluation if a target can be discarded
%w[tmp tmp/cache tmp/work].freeze
Instance Attribute Summary
Attributes inherited from BaseAttachmentService
#logger, #new_disk_path, #old_disk_path
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project:, old_disk_path:, logger: nil) ⇒ MigrateAttachmentsService
constructor
A new instance of MigrateAttachmentsService.
-
#target_path_discardable?(new_path) ⇒ Boolean
Check if target path has discardable content.
Methods included from Gitlab::Utils::Override
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
Methods inherited from BaseAttachmentService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(project:, old_disk_path:, logger: nil) ⇒ MigrateAttachmentsService
Returns a new instance of MigrateAttachmentsService.
11 12 13 14 15 |
# File 'app/services/projects/hashed_storage/migrate_attachments_service.rb', line 11 def initialize(project:, old_disk_path:, logger: nil) super @skipped = false end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/projects/hashed_storage/migrate_attachments_service.rb', line 17 def execute origin = (project) project.storage_version = ::Project::HASHED_STORAGE_FEATURES[:attachments] target = FileUploader.absolute_base_dir(project) @new_disk_path = project.disk_path result = move_folder!(origin, target) if result project.save!(validate: false) yield if block_given? end result end |
#target_path_discardable?(new_path) ⇒ Boolean
Check if target path has discardable content
41 42 43 44 45 46 47 |
# File 'app/services/projects/hashed_storage/migrate_attachments_service.rb', line 41 def target_path_discardable?(new_path) return false unless File.directory?(new_path) found = Dir.glob(File.join(new_path, '**', '**')) (found - discardable_paths(new_path)).empty? end |