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
f4c7fea6
Commit
f4c7fea6
authored
Nov 15, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dumping hashed storage based repository
parent
a4072db0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
9 deletions
+21
-9
app/models/project_wiki.rb
app/models/project_wiki.rb
+1
-1
lib/backup/repository.rb
lib/backup/repository.rb
+16
-8
spec/models/project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+4
-0
No files found.
app/models/project_wiki.rb
View file @
f4c7fea6
...
@@ -21,7 +21,7 @@ class ProjectWiki
...
@@ -21,7 +21,7 @@ class ProjectWiki
end
end
delegate
:empty?
,
to: :pages
delegate
:empty?
,
to: :pages
delegate
:repository_storage_path
,
to: :project
delegate
:repository_storage_path
,
:hashed_storage?
,
to: :project
def
path
def
path
@project
.
path
+
'.wiki'
@project
.
path
+
'.wiki'
...
...
lib/backup/repository.rb
View file @
f4c7fea6
...
@@ -7,12 +7,16 @@ module Backup
...
@@ -7,12 +7,16 @@ module Backup
prepare
prepare
Project
.
find_each
(
batch_size:
1000
)
do
|
project
|
Project
.
find_each
(
batch_size:
1000
)
do
|
project
|
progress
.
print
" *
#{
project
.
full_path
}
... "
progress
.
print
" *
#{
display_repo_path
(
project
)
}
... "
path_to_project_repo
=
path_to_repo
(
project
)
path_to_project_repo
=
path_to_repo
(
project
)
path_to_project_bundle
=
path_to_bundle
(
project
)
path_to_project_bundle
=
path_to_bundle
(
project
)
# Create namespace dir if missing
# Create namespace dir or hashed path if missing
if
project
.
hashed_storage?
(
:repository
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
File
.
join
(
backup_repos_path
,
project
.
disk_path
)))
else
FileUtils
.
mkdir_p
(
File
.
join
(
backup_repos_path
,
project
.
namespace
.
full_path
))
if
project
.
namespace
FileUtils
.
mkdir_p
(
File
.
join
(
backup_repos_path
,
project
.
namespace
.
full_path
))
if
project
.
namespace
end
if
empty_repo?
(
project
)
if
empty_repo?
(
project
)
progress
.
puts
"[SKIPPED]"
.
color
(
:cyan
)
progress
.
puts
"[SKIPPED]"
.
color
(
:cyan
)
...
@@ -42,7 +46,7 @@ module Backup
...
@@ -42,7 +46,7 @@ module Backup
path_to_wiki_bundle
=
path_to_bundle
(
wiki
)
path_to_wiki_bundle
=
path_to_bundle
(
wiki
)
if
File
.
exist?
(
path_to_wiki_repo
)
if
File
.
exist?
(
path_to_wiki_repo
)
progress
.
print
" *
#{
wiki
.
full_path
}
... "
progress
.
print
" *
#{
display_repo_path
(
wiki
)
}
... "
if
empty_repo?
(
wiki
)
if
empty_repo?
(
wiki
)
progress
.
puts
" [SKIPPED]"
.
color
(
:cyan
)
progress
.
puts
" [SKIPPED]"
.
color
(
:cyan
)
else
else
...
@@ -71,7 +75,7 @@ module Backup
...
@@ -71,7 +75,7 @@ module Backup
end
end
Project
.
find_each
(
batch_size:
1000
)
do
|
project
|
Project
.
find_each
(
batch_size:
1000
)
do
|
project
|
progress
.
print
" *
#{
project
.
full_path
}
... "
progress
.
print
" *
#{
display_repo_path
(
project
)
}
... "
path_to_project_repo
=
path_to_repo
(
project
)
path_to_project_repo
=
path_to_repo
(
project
)
path_to_project_bundle
=
path_to_bundle
(
project
)
path_to_project_bundle
=
path_to_bundle
(
project
)
...
@@ -104,7 +108,7 @@ module Backup
...
@@ -104,7 +108,7 @@ module Backup
path_to_wiki_bundle
=
path_to_bundle
(
wiki
)
path_to_wiki_bundle
=
path_to_bundle
(
wiki
)
if
File
.
exist?
(
path_to_wiki_bundle
)
if
File
.
exist?
(
path_to_wiki_bundle
)
progress
.
print
" *
#{
wiki
.
full_path
}
... "
progress
.
print
" *
#{
display_repo_path
(
wiki
)
}
... "
# If a wiki bundle exists, first remove the empty repo
# If a wiki bundle exists, first remove the empty repo
# that was initialized with ProjectWiki.new() and then
# that was initialized with ProjectWiki.new() and then
...
@@ -185,14 +189,14 @@ module Backup
...
@@ -185,14 +189,14 @@ module Backup
def
progress_warn
(
project
,
cmd
,
output
)
def
progress_warn
(
project
,
cmd
,
output
)
progress
.
puts
"[WARNING] Executing
#{
cmd
}
"
.
color
(
:orange
)
progress
.
puts
"[WARNING] Executing
#{
cmd
}
"
.
color
(
:orange
)
progress
.
puts
"Ignoring error on
#{
project
.
full_path
}
-
#{
output
}
"
.
color
(
:orange
)
progress
.
puts
"Ignoring error on
#{
display_repo_path
(
project
)
}
-
#{
output
}
"
.
color
(
:orange
)
end
end
def
empty_repo?
(
project_or_wiki
)
def
empty_repo?
(
project_or_wiki
)
project_or_wiki
.
repository
.
expire_exists_cache
# protect backups from stale cache
project_or_wiki
.
repository
.
expire_exists_cache
# protect backups from stale cache
project_or_wiki
.
repository
.
empty_repo?
project_or_wiki
.
repository
.
empty_repo?
rescue
=>
e
rescue
=>
e
progress
.
puts
"Ignoring repository error and continuing backing up project:
#{
project_or_wiki
.
full_path
}
-
#{
e
.
message
}
"
.
color
(
:orange
)
progress
.
puts
"Ignoring repository error and continuing backing up project:
#{
display_repo_path
(
project_or_wiki
)
}
-
#{
e
.
message
}
"
.
color
(
:orange
)
false
false
end
end
...
@@ -204,5 +208,9 @@ module Backup
...
@@ -204,5 +208,9 @@ module Backup
def
progress
def
progress
$progress
$progress
end
end
def
display_repo_path
(
project
)
project
.
hashed_storage?
(
:repository
)
?
"
#{
project
.
full_path
}
(
#{
project
.
disk_path
}
)"
:
project
.
full_path
end
end
end
end
end
spec/models/project_wiki_spec.rb
View file @
f4c7fea6
...
@@ -10,6 +10,10 @@ describe ProjectWiki do
...
@@ -10,6 +10,10 @@ describe ProjectWiki do
subject
{
project_wiki
}
subject
{
project_wiki
}
it
{
is_expected
.
to
delegate_method
(
:empty?
).
to
:pages
}
it
{
is_expected
.
to
delegate_method
(
:repository_storage_path
).
to
:project
}
it
{
is_expected
.
to
delegate_method
(
:hashed_storage?
).
to
:project
}
describe
"#path_with_namespace"
do
describe
"#path_with_namespace"
do
it
"returns the project path with namespace with the .wiki extension"
do
it
"returns the project path with namespace with the .wiki extension"
do
expect
(
subject
.
path_with_namespace
).
to
eq
(
project
.
full_path
+
'.wiki'
)
expect
(
subject
.
path_with_namespace
).
to
eq
(
project
.
full_path
+
'.wiki'
)
...
...
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