Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
4ded0411
Commit
4ded0411
authored
Dec 05, 2018
by
Jan Provaznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow pass additional options to use_fast_destroy
These options are then used when setting before destroy callback.
parent
9ccf8d03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
8 deletions
+4
-8
app/models/concerns/fast_destroy_all.rb
app/models/concerns/fast_destroy_all.rb
+2
-2
app/models/concerns/with_uploads.rb
app/models/concerns/with_uploads.rb
+2
-6
No files found.
app/models/concerns/fast_destroy_all.rb
View file @
4ded0411
...
...
@@ -76,8 +76,8 @@ module FastDestroyAll
##
# This method is to be defined on models which have fast destroyable models as children,
# and let us avoid to use `dependent: :destroy` hook
def
use_fast_destroy
(
relation
)
before_destroy
(
prepend:
true
)
do
def
use_fast_destroy
(
relation
,
opts
=
{}
)
set_callback
:destroy
,
:before
,
opts
.
merge
(
prepend:
true
)
do
perform_fast_destroy
(
public_send
(
relation
))
# rubocop:disable GitlabSecurity/PublicSend
end
end
...
...
app/models/concerns/with_uploads.rb
View file @
4ded0411
...
...
@@ -31,13 +31,9 @@ module WithUploads
# TODO: when feature flag is removed, we can use just dependent: destroy
# option on :file_uploads
before_destroy
:remove_file_uploads
before_destroy
:remove_file_uploads
,
unless: :fast_destroy_enabled?
use_fast_destroy
:file_uploads
end
def
perform_fast_destroy
(
subject
)
super
if
fast_destroy_enabled?
use_fast_destroy
:file_uploads
,
if: :fast_destroy_enabled?
end
def
retrieve_upload
(
_identifier
,
paths
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment