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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c56eca3f
Commit
c56eca3f
authored
Apr 20, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move repository creation to the synchronized block
This ensures that we only call create on the repo once
parent
abd78e4d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
6 deletions
+7
-6
ee/app/models/design_management/version.rb
ee/app/models/design_management/version.rb
+2
-1
ee/app/services/design_management/delete_designs_service.rb
ee/app/services/design_management/delete_designs_service.rb
+1
-1
ee/app/services/design_management/runs_design_actions.rb
ee/app/services/design_management/runs_design_actions.rb
+3
-1
ee/app/services/design_management/save_designs_service.rb
ee/app/services/design_management/save_designs_service.rb
+1
-3
No files found.
ee/app/models/design_management/version.rb
View file @
c56eca3f
...
...
@@ -98,10 +98,11 @@ module DesignManagement
CREATION_TTL
=
5
.
seconds
RETRY_DELAY
=
->
(
num
)
{
0.2
.
seconds
*
num
**
2
}
def
self
.
lock_for_creation
(
project_id
,
&
block
)
def
self
.
lock_for_creation
(
project_id
,
repository
,
&
block
)
key
=
"lock_for_creation:
#{
name
}
:{
#{
project_id
}
}"
in_lock
(
key
,
ttl:
CREATION_TTL
,
retries:
5
,
sleep_sec:
RETRY_DELAY
)
do
|
_retried
|
repository
.
create_if_not_exists
yield
end
end
...
...
ee/app/services/design_management/delete_designs_service.rb
View file @
c56eca3f
...
...
@@ -37,7 +37,7 @@ module DesignManagement
attr_reader
:designs
def
delete_designs!
DesignManagement
::
Version
.
lock_for_creation
(
project
.
id
)
do
DesignManagement
::
Version
.
lock_for_creation
(
project
.
id
,
repository
)
do
run_actions
(
build_actions
)
end
end
...
...
ee/app/services/design_management/runs_design_actions.rb
View file @
c56eca3f
...
...
@@ -7,11 +7,13 @@ module DesignManagement
# this concern requires the following methods to be implemented:
# current_user, target_branch, repository, commit_message
#
# Before calling `run_actions`, you should ensure the repository exists, by
# calling `repository.create_if_not_exists`.
#
# @raise [NoActions] if actions are empty
def
run_actions
(
actions
)
raise
NoActions
if
actions
.
empty?
repository
.
create_if_not_exists
sha
=
repository
.
multi_action
(
current_user
,
branch_name:
target_branch
,
message:
commit_message
,
...
...
ee/app/services/design_management/save_designs_service.rb
View file @
c56eca3f
...
...
@@ -33,9 +33,7 @@ module DesignManagement
attr_reader
:files
def
upload_designs!
::
DesignManagement
::
Version
.
lock_for_creation
(
project
.
id
)
do
repository
.
create_if_not_exists
::
DesignManagement
::
Version
.
lock_for_creation
(
project
.
id
,
repository
)
do
actions
=
build_actions
[
actions
.
map
(
&
:design
),
actions
.
presence
&&
run_actions
(
actions
)]
...
...
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