Class: Gitlab::Cleanup::ProjectUploads::ProjectUploadPath
- Inherits:
-
Object
- Object
- Gitlab::Cleanup::ProjectUploads::ProjectUploadPath
- Defined in:
- lib/gitlab/cleanup/project_uploads.rb
Constant Summary collapse
- PROJECT_FULL_PATH_REGEX =
%r{\A#{FileUploader.root}/(.+)/(\h+/[^/]+)\z}
Instance Attribute Summary collapse
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#upload_path ⇒ Object
readonly
Returns the value of attribute upload_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(full_path, upload_path) ⇒ ProjectUploadPath
constructor
A new instance of ProjectUploadPath.
-
#orphan? ⇒ Boolean
rubocop: disable CodeReuse/ActiveRecord.
Constructor Details
#initialize(full_path, upload_path) ⇒ ProjectUploadPath
Returns a new instance of ProjectUploadPath.
100 101 102 103 |
# File 'lib/gitlab/cleanup/project_uploads.rb', line 100 def initialize(full_path, upload_path) @full_path = full_path @upload_path = upload_path end |
Instance Attribute Details
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
98 99 100 |
# File 'lib/gitlab/cleanup/project_uploads.rb', line 98 def full_path @full_path end |
#upload_path ⇒ Object (readonly)
Returns the value of attribute upload_path.
98 99 100 |
# File 'lib/gitlab/cleanup/project_uploads.rb', line 98 def upload_path @upload_path end |
Class Method Details
.from_path(path) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/gitlab/cleanup/project_uploads.rb', line 105 def self.from_path(path) path_matched = path.match(PROJECT_FULL_PATH_REGEX) return new(nil, nil) unless path_matched new(path_matched[1], path_matched[2]) end |
Instance Method Details
#orphan? ⇒ Boolean
rubocop: disable CodeReuse/ActiveRecord
113 114 115 116 117 118 |
# File 'lib/gitlab/cleanup/project_uploads.rb', line 113 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 |