Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
dec5c58fa805
Commit
68c67232
authored
Mar 13, 2018
by
Michael Kozono
Browse files
Appease Metrics/AbcSize cop
parent
a607b8ee508b
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/models/concerns/storage/legacy_namespace.rb
View file @
dec5c58f
...
...
@@ -13,26 +13,10 @@ def move_dir
expires_full_path_cache
# Move the namespace directory in all storage paths used by member projects
repository_storage_paths
.
each
do
|
repository_storage_path
|
# Ensure old directory exists before moving it
gitlab_shell
.
add_namespace
(
repository_storage_path
,
full_path_was
)
# Ensure new directory exists before moving it (if there's a parent)
gitlab_shell
.
add_namespace
(
repository_storage_path
,
parent
.
full_path
)
if
parent
unless
gitlab_shell
.
mv_namespace
(
repository_storage_path
,
full_path_was
,
full_path
)
Rails
.
logger
.
error
"Exception moving path
#{
repository_storage_path
}
from
#{
full_path_was
}
to
#{
full_path
}
"
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise
Gitlab
::
UpdatePathError
.
new
(
'namespace directory cannot be moved'
)
end
end
move_repositories
if
parent_changed?
former_parent_full_path
=
parent_was
.
full_path
former_parent_full_path
=
parent_was
&
.
full_path
parent_full_path
=
parent
&
.
full_path
Gitlab
::
UploadsTransfer
.
new
.
move_namespace
(
path
,
former_parent_full_path
,
parent_full_path
)
Gitlab
::
PagesTransfer
.
new
.
move_namespace
(
path
,
former_parent_full_path
,
parent_full_path
)
...
...
@@ -68,6 +52,26 @@ def prepare_for_destroy
private
def
move_repositories
# Move the namespace directory in all storage paths used by member projects
repository_storage_paths
.
each
do
|
repository_storage_path
|
# Ensure old directory exists before moving it
gitlab_shell
.
add_namespace
(
repository_storage_path
,
full_path_was
)
# Ensure new directory exists before moving it (if there's a parent)
gitlab_shell
.
add_namespace
(
repository_storage_path
,
parent
.
full_path
)
if
parent
unless
gitlab_shell
.
mv_namespace
(
repository_storage_path
,
full_path_was
,
full_path
)
Rails
.
logger
.
error
"Exception moving path
#{
repository_storage_path
}
from
#{
full_path_was
}
to
#{
full_path
}
"
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise
Gitlab
::
UpdatePathError
.
new
(
'namespace directory cannot be moved'
)
end
end
end
def
old_repository_storage_paths
@old_repository_storage_paths
||=
repository_storage_paths
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