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
0aa8249e
Commit
0aa8249e
authored
Jul 06, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactors Project Destroy service and worker code
parent
3491b19a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
21 deletions
+28
-21
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+26
-16
app/workers/project_destroy_worker.rb
app/workers/project_destroy_worker.rb
+2
-5
No files found.
app/services/projects/destroy_service.rb
View file @
0aa8249e
...
...
@@ -25,27 +25,15 @@ module Projects
Projects
::
UnlinkForkService
.
new
(
project
,
current_user
).
execute
Project
.
transaction
do
unless
remove_legacy_registry_tags
raise_error
(
'Failed to remove some tags in project container registry. Please try again or contact administrator.'
)
end
unless
remove_repository
(
repo_path
)
raise_error
(
'Failed to remove project repository. Please try again or contact administrator.'
)
end
unless
remove_repository
(
wiki_path
)
raise_error
(
'Failed to remove wiki repository. Please try again or contact administrator.'
)
end
project
.
team
.
truncate
project
.
destroy!
end
attempt_destroy_transaction
(
project
,
repo_path
,
wiki_path
)
system_hook_service
.
execute_hooks_for
(
project
,
:destroy
)
log_info
(
"Project
\"
#{
project
.
full_path
}
\"
was removed"
)
true
rescue
Projects
::
DestroyService
::
DestroyError
=>
error
Rails
.
logger
.
error
(
"Deletion failed on
#{
project
.
full_path
}
with the following message:
#{
error
.
message
}
"
)
false
end
private
...
...
@@ -71,6 +59,28 @@ module Projects
end
end
def
attempt_destroy_transaction
(
project
,
repo_path
,
wiki_path
)
Project
.
transaction
do
unless
remove_legacy_registry_tags
raise_error
(
'Failed to remove some tags in project container registry. Please try again or contact administrator.'
)
end
unless
remove_repository
(
repo_path
)
raise_error
(
'Failed to remove project repository. Please try again or contact administrator.'
)
end
unless
remove_repository
(
wiki_path
)
raise_error
(
'Failed to remove wiki repository. Please try again or contact administrator.'
)
end
project
.
team
.
truncate
project
.
destroy!
end
rescue
Exception
=>
error
# rubocop:disable Lint/RescueException
project
.
update_attributes
(
delete_error:
error
.
message
,
pending_delete:
false
)
raise
end
##
# This method makes sure that we correctly remove registry tags
# for legacy image repository (when repository path equals project path).
...
...
app/workers/project_destroy_worker.rb
View file @
0aa8249e
...
...
@@ -7,10 +7,7 @@ class ProjectDestroyWorker
user
=
User
.
find
(
user_id
)
::
Projects
::
DestroyService
.
new
(
project
,
user
,
params
.
symbolize_keys
).
execute
rescue
Exception
=>
error
# rubocop:disable Lint/RescueException
project
&
.
update_attributes
(
delete_error:
error
.
message
,
pending_delete:
false
)
Rails
.
logger
.
error
(
"Deletion failed on
#{
project
&
.
full_path
}
with the following message:
#{
error
.
message
}
"
)
raise
rescue
ActiveRecord
::
RecordNotFound
=>
error
logger
.
error
(
"Failed to delete project
#{
project
.
path_with_namespace
}
(
#{
project
.
id
}
):
#{
error
.
message
}
"
)
end
end
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