diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-02-05 12:39:46 +0100 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-02-12 12:30:27 -0200 |
commit | c3782d20afc421cee972df0fa26e9a8e67210f52 (patch) | |
tree | aac4caa9173b19f2ea77585fee4806ebd8f2f55f /app/models | |
parent | 453dec0a575bce9db8df6003f3de62228bec1f53 (diff) | |
download | gitlab-ce-c3782d20afc421cee972df0fa26e9a8e67210f52.tar.gz |
Remove fast_destroy_uploads feature flag
Fast destroy of uploads was successfully enabled and test.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/with_uploads.rb | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/app/models/concerns/with_uploads.rb b/app/models/concerns/with_uploads.rb index d79c0eae77e..6c6febd186c 100644 --- a/app/models/concerns/with_uploads.rb +++ b/app/models/concerns/with_uploads.rb @@ -27,40 +27,14 @@ module WithUploads included do has_many :uploads, as: :model - has_many :file_uploads, -> { where(uploader: FILE_UPLOADERS) }, class_name: 'Upload', as: :model + has_many :file_uploads, -> { where(uploader: FILE_UPLOADERS) }, + class_name: 'Upload', as: :model, + dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent - # TODO: when feature flag is removed, we can use just dependent: destroy - # option on :file_uploads - before_destroy :remove_file_uploads - - use_fast_destroy :file_uploads, if: :fast_destroy_enabled? + use_fast_destroy :file_uploads end def retrieve_upload(_identifier, paths) uploads.find_by(path: paths) end - - private - - # mounted uploads are deleted in carrierwave's after_commit hook, - # but FileUploaders which are not mounted must be deleted explicitly and - # it can not be done in after_commit because FileUploader requires loads - # associated model on destroy (which is already deleted in after_commit) - def remove_file_uploads - fast_destroy_enabled? ? delete_uploads : destroy_uploads - end - - def delete_uploads - file_uploads.delete_all(:delete_all) - end - - def destroy_uploads - file_uploads.find_each do |upload| - upload.destroy - end - end - - def fast_destroy_enabled? - Feature.enabled?(:fast_destroy_uploads, self) - end end |