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
Jérome Perrin
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
Show 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,12 +102,16 @@ class Namespace < ActiveRecord::Base
...
@@ -102,12 +102,16 @@ class Namespace < ActiveRecord::Base
# Move namespace directory into trash.
# Move namespace directory into trash.
# We will remove it later async
# We will remove it later async
new_path
=
"
#{
path
}
+
#{
id
}
+deleted"
new_path
=
"
#{
path
}
+
#{
id
}
+deleted"
gitlab_shell
.
mv_namespace
(
path
,
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
# Remove namespace directroy async with delay so
# GitLab has time to remove all projects first
# GitLab has time to remove all projects first
GitlabShellWorker
.
perform_in
(
5
.
minutes
,
:rm_namespace
,
new_path
)
GitlabShellWorker
.
perform_in
(
5
.
minutes
,
:rm_namespace
,
new_path
)
end
end
end
def
move_dir
def
move_dir
if
gitlab_shell
.
mv_namespace
(
path_was
,
path
)
if
gitlab_shell
.
mv_namespace
(
path_was
,
path
)
...
...
app/services/delete_user_service.rb
View file @
53a0ac47
...
@@ -4,9 +4,10 @@ class DeleteUserService
...
@@ -4,9 +4,10 @@ class DeleteUserService
user
.
errors
[
:base
]
<<
'You must transfer ownership or delete groups before you can remove user'
user
.
errors
[
:base
]
<<
'You must transfer ownership or delete groups before you can remove user'
user
user
else
else
# TODO: Skip remove repository so Namespace#rm_dir works
user
.
personal_projects
.
each
do
|
project
|
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
end
user
.
destroy
user
.
destroy
...
...
app/services/destroy_group_service.rb
View file @
53a0ac47
...
@@ -6,9 +6,10 @@ class DestroyGroupService
...
@@ -6,9 +6,10 @@ class DestroyGroupService
end
end
def
execute
def
execute
# TODO: Skip remove repository so Namespace#rm_dir works
@group
.
projects
.
each
do
|
project
|
@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
end
@group
.
destroy
@group
.
destroy
...
...
app/services/projects/destroy_service.rb
View file @
53a0ac47
...
@@ -36,9 +36,11 @@ module Projects
...
@@ -36,9 +36,11 @@ module Projects
private
private
def
remove_repository
(
path
)
def
remove_repository
(
path
)
unless
gitlab_shell
.
exists?
(
path
+
'.git'
)
# Skip repository removal. We use this flag when remove user or group
return
true
return
true
if
params
[
:skip_repo
]
==
true
end
# There is a possibility project does not have repository or wiki
return
true
unless
gitlab_shell
.
exists?
(
path
+
'.git'
)
new_path
=
removal_path
(
path
)
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