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
53a0ac47
Commit
53a0ac47
authored
Jun 03, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip repo removing whem remove user or group
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
47a95754
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
11 deletions
+63
-11
app/models/namespace.rb
app/models/namespace.rb
+8
-4
app/services/delete_user_service.rb
app/services/delete_user_service.rb
+3
-2
app/services/destroy_group_service.rb
app/services/destroy_group_service.rb
+3
-2
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+5
-3
spec/services/destroy_group_service_spec.rb
spec/services/destroy_group_service_spec.rb
+44
-0
No files found.
app/models/namespace.rb
View file @
53a0ac47
...
...
@@ -102,11 +102,15 @@ class Namespace < ActiveRecord::Base
# Move namespace directory into trash.
# We will remove it later async
new_path
=
"
#{
path
}
+
#{
id
}
+deleted"
gitlab_shell
.
mv_namespace
(
path
,
new_path
)
# Remove namespace directroy async with delay so
# GitLab has time to remove all projects first
GitlabShellWorker
.
perform_in
(
5
.
minutes
,
:rm_namespace
,
new_path
)
if
gitlab_shell
.
mv_namespace
(
path
,
new_path
)
message
=
"Namespace directory
\"
#{
path
}
\"
moved to
\"
#{
new_path
}
\"
"
Gitlab
::
AppLogger
.
info
message
# Remove namespace directroy async with delay so
# GitLab has time to remove all projects first
GitlabShellWorker
.
perform_in
(
5
.
minutes
,
:rm_namespace
,
new_path
)
end
end
def
move_dir
...
...
app/services/delete_user_service.rb
View file @
53a0ac47
...
...
@@ -4,9 +4,10 @@ class DeleteUserService
user
.
errors
[
:base
]
<<
'You must transfer ownership or delete groups before you can remove user'
user
else
# TODO: Skip remove repository so Namespace#rm_dir works
user
.
personal_projects
.
each
do
|
project
|
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
{}).
execute
# Skip repository removal because we remove directory with namespace
# that contain all this repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
execute
end
user
.
destroy
...
...
app/services/destroy_group_service.rb
View file @
53a0ac47
...
...
@@ -6,9 +6,10 @@ class DestroyGroupService
end
def
execute
# TODO: Skip remove repository so Namespace#rm_dir works
@group
.
projects
.
each
do
|
project
|
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
{}).
execute
# Skip repository removal because we remove directory with namespace
# that contain all this repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
execute
end
@group
.
destroy
...
...
app/services/projects/destroy_service.rb
View file @
53a0ac47
...
...
@@ -36,9 +36,11 @@ module Projects
private
def
remove_repository
(
path
)
unless
gitlab_shell
.
exists?
(
path
+
'.git'
)
return
true
end
# Skip repository removal. We use this flag when remove user or group
return
true
if
params
[
:skip_repo
]
==
true
# There is a possibility project does not have repository or wiki
return
true
unless
gitlab_shell
.
exists?
(
path
+
'.git'
)
new_path
=
removal_path
(
path
)
...
...
spec/services/destroy_group_service_spec.rb
0 → 100644
View file @
53a0ac47
require
'spec_helper'
describe
DestroyGroupService
do
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let!
(
:remove_path
)
{
group
.
path
+
"+
#{
group
.
id
}
+deleted"
}
context
'database records'
do
before
do
destroy_group
(
group
,
user
)
end
it
{
Group
.
all
.
should_not
include
(
group
)
}
it
{
Project
.
all
.
should_not
include
(
project
)
}
end
context
'file system'
do
context
'Sidekiq inline'
do
before
do
# Run sidekiq immediatly to check that renamed dir will be removed
Sidekiq
::
Testing
.
inline!
{
destroy_group
(
group
,
user
)
}
end
it
{
gitlab_shell
.
exists?
(
group
.
path
).
should
be_falsey
}
it
{
gitlab_shell
.
exists?
(
remove_path
).
should
be_falsey
}
end
context
'Sidekiq fake'
do
before
do
# Dont run sidekiq to check if renamed repository exists
Sidekiq
::
Testing
.
fake!
{
destroy_group
(
group
,
user
)
}
end
it
{
gitlab_shell
.
exists?
(
group
.
path
).
should
be_falsey
}
it
{
gitlab_shell
.
exists?
(
remove_path
).
should
be_truthy
}
end
end
def
destroy_group
(
group
,
user
)
DestroyGroupService
.
new
(
group
,
user
).
execute
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