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
bab49fdf
Commit
bab49fdf
authored
Jul 25, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect backups from stale cache for repo exists
parent
4c89929f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
lib/backup/repository.rb
lib/backup/repository.rb
+1
-0
spec/lib/gitlab/backup/repository_spec.rb
spec/lib/gitlab/backup/repository_spec.rb
+54
-0
No files found.
lib/backup/repository.rb
View file @
bab49fdf
...
@@ -189,6 +189,7 @@ module Backup
...
@@ -189,6 +189,7 @@ module Backup
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
.
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
.
path_with_namespace
}
-
#{
e
.
message
}
"
.
color
(
:orange
)
progress
.
puts
"Ignoring repository error and continuing backing up project:
#{
project_or_wiki
.
path_with_namespace
}
-
#{
e
.
message
}
"
.
color
(
:orange
)
...
...
spec/lib/gitlab/backup/repository_spec.rb
View file @
bab49fdf
...
@@ -60,4 +60,58 @@ describe Backup::Repository do
...
@@ -60,4 +60,58 @@ describe Backup::Repository do
end
end
end
end
end
end
describe
'#empty_repo?'
do
context
'for a wiki'
do
let
(
:wiki
)
{
create
(
:project_wiki
)
}
context
'wiki repo has content'
do
let!
(
:wiki_page
)
{
create
(
:wiki_page
,
wiki:
wiki
)
}
before
do
wiki
.
repository
.
exists?
# initial cache
end
context
'`repository.exists?` is incorrectly cached as false'
do
before
do
repo
=
wiki
.
repository
repo
.
send
(
:cache
).
expire
(
:exists?
)
repo
.
send
(
:cache
).
fetch
(
:exists?
)
{
false
}
repo
.
send
(
:instance_variable_set
,
:@exists
,
false
)
end
it
'returns false, regardless of bad cache value'
do
expect
(
Backup
::
Repository
.
new
.
send
(
:empty_repo?
,
wiki
)).
to
be_falsey
end
end
context
'`repository.exists?` is correctly cached as true'
do
it
'returns false'
do
expect
(
Backup
::
Repository
.
new
.
send
(
:empty_repo?
,
wiki
)).
to
be_falsey
end
end
end
context
'wiki repo does not have content'
do
context
'`repository.exists?` is incorrectly cached as true'
do
before
do
repo
=
wiki
.
repository
repo
.
send
(
:cache
).
expire
(
:exists?
)
repo
.
send
(
:cache
).
fetch
(
:exists?
)
{
true
}
repo
.
send
(
:instance_variable_set
,
:@exists
,
true
)
end
it
'returns true, regardless of bad cache value'
do
expect
(
Backup
::
Repository
.
new
.
send
(
:empty_repo?
,
wiki
)).
to
be_truthy
end
end
context
'`repository.exists?` is correctly cached as false'
do
it
'returns true'
do
expect
(
Backup
::
Repository
.
new
.
send
(
:empty_repo?
,
wiki
)).
to
be_truthy
end
end
end
end
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