Class: Gitlab::Cleanup::ProjectUploadFileFinder

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

Constant Summary collapse

FIND_BATCH_SIZE =
500
ABSOLUTE_UPLOAD_DIR =
FileUploader.root.freeze
EXCLUDED_SYSTEM_UPLOADS_PATH =
"#{ABSOLUTE_UPLOAD_DIR}/-/*"
EXCLUDED_HASHED_UPLOADS_PATH =
"#{ABSOLUTE_UPLOAD_DIR}/@hashed/*"
EXCLUDED_TMP_UPLOADS_PATH =
"#{ABSOLUTE_UPLOAD_DIR}/tmp/*"

Instance Method Summary collapse

Instance Method Details

#each_file_batch(batch_size: FIND_BATCH_SIZE, &block) ⇒ Object

Paths are relative to the upload directory


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

def each_file_batch(batch_size: FIND_BATCH_SIZE, &block)
  cmd = build_find_command(ABSOLUTE_UPLOAD_DIR)

  Open3.popen2(*cmd) do |stdin, stdout, status_thread|
    yield_paths_in_batches(stdout, batch_size, &block)

    raise "Find command failed" unless status_thread.value.success?
  end
end