Class: Gitlab::Cleanup::ProjectUploads

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/cleanup/project_uploads.rb

Defined Under Namespace

Classes: ProjectUploadPath

Constant Summary collapse

LOST_AND_FOUND =
File.join(ProjectUploadFileFinder::ABSOLUTE_UPLOAD_DIR, '-', 'project-lost-found')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger: nil) ⇒ ProjectUploads

Returns a new instance of ProjectUploads.


10
11
12
# File 'lib/gitlab/cleanup/project_uploads.rb', line 10

def initialize(logger: nil)
  @logger = logger || Gitlab::AppLogger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger


8
9
10
# File 'lib/gitlab/cleanup/project_uploads.rb', line 8

def logger
  @logger
end

Instance Method Details

#run!(dry_run: true) ⇒ Object


14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/cleanup/project_uploads.rb', line 14

def run!(dry_run: true)
  logger.info "Looking for orphaned project uploads to clean up#{'. Dry run' if dry_run}..."

  each_orphan_file do |path, upload_path|
    result = cleanup(path, upload_path, dry_run)

    logger.info result
  end
end