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
Léo-Paul Géneau
gitlab-ce
Commits
46152c2c
Commit
46152c2c
authored
Feb 20, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'sh-namespace-cleanup-deleted-projects' into 'master'"
This reverts commit
1f12aaf2
.
parent
51f82b3b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
59 deletions
+5
-59
app/models/namespace.rb
app/models/namespace.rb
+2
-14
app/models/project.rb
app/models/project.rb
+0
-2
app/services/groups/destroy_service.rb
app/services/groups/destroy_service.rb
+0
-27
spec/services/destroy_group_service_spec.rb
spec/services/destroy_group_service_spec.rb
+3
-16
No files found.
app/models/namespace.rb
View file @
46152c2c
...
...
@@ -35,7 +35,7 @@ class Namespace < ActiveRecord::Base
after_commit
:refresh_access_of_projects_invited_groups
,
on: :update
,
if:
->
{
previous_changes
.
key?
(
'share_with_group_lock'
)
}
# Save the storage paths before the projects are destroyed to use them on after destroy
before_destroy
(
prepend:
true
)
{
prepare_for_destroy
}
before_destroy
(
prepend:
true
)
{
@old_repository_storage_paths
=
repository_storage_paths
}
after_destroy
:rm_dir
scope
:root
,
->
{
where
(
'type IS NULL'
)
}
...
...
@@ -217,18 +217,6 @@ class Namespace < ActiveRecord::Base
[
owner_id
]
end
def
parent_changed?
parent_id_changed?
end
def
prepare_for_destroy
old_repository_storage_paths
end
def
old_repository_storage_paths
@old_repository_storage_paths
||=
repository_storage_paths
end
private
def
repository_storage_paths
...
...
@@ -242,7 +230,7 @@ class Namespace < ActiveRecord::Base
def
rm_dir
# Remove the namespace directory in all storages paths used by member projects
old_repository_storage_paths
.
each
do
|
repository_storage_path
|
@
old_repository_storage_paths
.
each
do
|
repository_storage_path
|
# Move namespace directory into trash.
# We will remove it later async
new_path
=
"
#{
path
}
+
#{
id
}
+deleted"
...
...
app/models/project.rb
View file @
46152c2c
...
...
@@ -214,8 +214,6 @@ class Project < ActiveRecord::Base
# Scopes
default_scope
{
where
(
pending_delete:
false
)
}
scope
:with_deleted
,
->
{
unscope
(
where: :pending_delete
)
}
scope
:sorted_by_activity
,
->
{
reorder
(
last_activity_at: :desc
)
}
scope
:sorted_by_stars
,
->
{
reorder
(
'projects.star_count DESC'
)
}
...
...
app/services/groups/destroy_service.rb
deleted
100644 → 0
View file @
51f82b3b
module
Groups
class
DestroyService
<
Groups
::
BaseService
def
async_execute
# Soft delete via paranoia gem
group
.
destroy
job_id
=
GroupDestroyWorker
.
perform_async
(
group
.
id
,
current_user
.
id
)
Rails
.
logger
.
info
(
"User
#{
current_user
.
id
}
scheduled a deletion of group ID
#{
group
.
id
}
with job ID
#{
job_id
}
"
)
end
def
execute
group
.
prepare_for_destroy
group
.
projects
.
with_deleted
.
each
do
|
project
|
# Execute the destruction of the models immediately to ensure atomic cleanup.
# Skip repository removal because we remove directory with namespace
# that contain all these repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
execute
end
group
.
children
.
each
do
|
group
|
DestroyService
.
new
(
group
,
current_user
).
async_execute
end
group
.
really_destroy!
end
end
end
spec/services/destroy_group_service_spec.rb
View file @
46152c2c
...
...
@@ -9,18 +9,14 @@ describe DestroyGroupService, services: true do
let!
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let!
(
:remove_path
)
{
group
.
path
+
"+
#{
group
.
id
}
+deleted"
}
before
do
group
.
add_user
(
user
,
Gitlab
::
Access
::
OWNER
)
end
shared_examples
'group destruction'
do
|
async
|
context
'database records'
do
before
do
destroy_group
(
group
,
user
,
async
)
end
it
{
expect
(
Group
.
unscoped
.
all
).
not_to
include
(
group
)
}
it
{
expect
(
Project
.
unscoped
.
all
).
not_to
include
(
project
)
}
it
{
expect
(
Group
.
all
).
not_to
include
(
group
)
}
it
{
expect
(
Project
.
all
).
not_to
include
(
project
)
}
end
context
'file system'
do
...
...
@@ -36,7 +32,7 @@ describe DestroyGroupService, services: true do
context
'Sidekiq fake'
do
before
do
# Don
'
t run sidekiq to check if renamed repository exists
# Dont run sidekiq to check if renamed repository exists
Sidekiq
::
Testing
.
fake!
{
destroy_group
(
group
,
user
,
async
)
}
end
...
...
@@ -99,13 +95,4 @@ describe DestroyGroupService, services: true do
describe
'synchronous delete'
do
it_behaves_like
'group destruction'
,
false
end
context
'projects in pending_delete'
do
before
do
project
.
pending_delete
=
true
project
.
save
end
it_behaves_like
'group destruction'
,
false
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