summaryrefslogtreecommitdiff
path: root/lib/gitlab/cleanup
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-08-27 17:31:01 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2018-09-11 17:32:00 +0200
commit2039c8280db1646845c33d6c5a74e5f23ca6f4de (patch)
treee2b3cd3012d9711cda7c6afb962ae4228d59521a /lib/gitlab/cleanup
parent91c40973dc620430b173ea2df968587d2a708dff (diff)
downloadgitlab-ce-2039c8280db1646845c33d6c5a74e5f23ca6f4de.tar.gz
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of which most are triggered by the CodeReuse/ActiveRecord cop.
Diffstat (limited to 'lib/gitlab/cleanup')
-rw-r--r--lib/gitlab/cleanup/project_uploads.rb6
-rw-r--r--lib/gitlab/cleanup/remote_uploads.rb2
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/cleanup/project_uploads.rb b/lib/gitlab/cleanup/project_uploads.rb
index f55ab535efe..82a405362c2 100644
--- a/lib/gitlab/cleanup/project_uploads.rb
+++ b/lib/gitlab/cleanup/project_uploads.rb
@@ -38,6 +38,7 @@ module Gitlab
end
# Accepts a path in the form of "#{hex_secret}/#{filename}"
+ # rubocop: disable CodeReuse/ActiveRecord
def find_correct_path(upload_path)
upload = Upload.find_by(uploader: 'FileUploader', path: upload_path)
return unless upload && upload.local? && upload.model
@@ -52,6 +53,7 @@ module Gitlab
# I.e. the project record might be missing, which raises an exception.
nil
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_to_lost_and_found(path, dry_run)
new_path = path.sub(/\A#{ProjectUploadFileFinder::ABSOLUTE_UPLOAD_DIR}/, LOST_AND_FOUND)
@@ -107,18 +109,22 @@ module Gitlab
new(path_matched[1], path_matched[2])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def orphan?
return true if full_path.nil? || upload_path.nil?
# It's possible to reduce to one query, but `where_full_path_in` is complex
!Upload.exists?(path: upload_path, model_id: project_id, model_type: 'Project', uploader: 'FileUploader')
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def project_id
@project_id ||= Project.where_full_path_in([full_path]).pluck(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/cleanup/remote_uploads.rb b/lib/gitlab/cleanup/remote_uploads.rb
index 45a5aea4fcd..eba1faacc3a 100644
--- a/lib/gitlab/cleanup/remote_uploads.rb
+++ b/lib/gitlab/cleanup/remote_uploads.rb
@@ -33,6 +33,7 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def each_orphan_file
# we want to skip files already moved to lost_and_found directory
lost_dir_match = "^#{lost_and_found_dir}\/"
@@ -50,6 +51,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_to_lost_and_found(file)
new_path = "#{lost_and_found_dir}/#{file.key}"