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
27d7a37c
Commit
27d7a37c
authored
Apr 22, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rename_repository replication support for Geo
parent
d3e2d9d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
0 deletions
+64
-0
app/services/geo/rename_repository_service.rb
app/services/geo/rename_repository_service.rb
+36
-0
app/services/geo/schedule_repo_rename_service.rb
app/services/geo/schedule_repo_rename_service.rb
+16
-0
app/workers/geo_repository_rename_worker.rb
app/workers/geo_repository_rename_worker.rb
+9
-0
lib/api/geo.rb
lib/api/geo.rb
+3
-0
No files found.
app/services/geo/rename_repository_service.rb
0 → 100644
View file @
27d7a37c
module
Geo
class
RenameRepositoryService
include
Gitlab
::
ShellAdapter
attr_reader
:id
,
:name
,
:old_path_with_namespace
,
:new_path_with_namespace
def
initialize
(
id
,
name
,
old_path_with_namespace
,
new_path_with_namespace
)
@id
=
id
@name
=
name
@old_path_with_namespace
=
old_path_with_namespace
@new_path_with_namespace
=
new_path_with_namespace
end
def
execute
project
=
Project
.
find
(
id
)
project
.
expire_caches_before_rename
(
old_path_with_namespace
)
if
gitlab_shell
.
mv_repository
(
old_path_with_namespace
,
new_path_with_namespace
)
# If repository moved successfully we need to send update instructions to users.
# However we cannot allow rollback since we moved repository
# So we basically we mute exceptions in next actions
begin
gitlab_shell
.
mv_repository
(
"
#{
old_path_with_namespace
}
.wiki"
,
"
#{
new_path_with_namespace
}
.wiki"
)
rescue
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
false
end
else
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise
Exception
.
new
(
'repository cannot be renamed'
)
end
end
end
end
app/services/geo/schedule_repo_rename_service.rb
0 → 100644
View file @
27d7a37c
module
Geo
class
ScheduleRepoRenameService
attr_reader
:id
,
:name
,
:old_path_with_namespace
,
:path_with_namespace
def
initialize
(
params
)
@id
=
params
[
'project_id'
]
@name
=
params
[
'name'
]
@old_path_with_namespace
=
params
[
'old_path_with_namespace'
]
@path_with_namespace
=
params
[
'path_with_namespace'
]
end
def
execute
GeoRepositoryRenameWorker
.
perform_async
(
id
,
name
,
old_path_with_namespace
,
path_with_namespace
)
end
end
end
app/workers/geo_repository_rename_worker.rb
0 → 100644
View file @
27d7a37c
class
GeoRepositoryRenameWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
id
,
name
,
old_path_with_namespace
,
new_path_with_namespace
)
Geo
::
RenameRepositoryService
.
new
(
id
,
name
,
old_path_with_namespace
,
new_path_with_namespace
).
execute
end
end
lib/api/geo.rb
View file @
27d7a37c
...
...
@@ -33,6 +33,9 @@ module API
when
'project_destroy'
required_attributes!
%w(event_name project_id path_with_namespace)
::
Geo
::
ScheduleRepoDestroyService
.
new
(
params
).
execute
when
'project_rename'
required_attributes!
%w(event_name project_id path_with_namespace old_path_with_namespace)
::
Geo
::
ScheduleRepoRenameService
.
new
(
params
).
execute
end
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