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
874a4ff1
Commit
874a4ff1
authored
Jul 10, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more object storage specs
parent
4c7b120a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
+26
-5
lib/gitlab/import_export/uploads_manager.rb
lib/gitlab/import_export/uploads_manager.rb
+3
-3
spec/lib/gitlab/import_export/uploads_manager_spec.rb
spec/lib/gitlab/import_export/uploads_manager_spec.rb
+23
-2
No files found.
lib/gitlab/import_export/uploads_manager.rb
View file @
874a4ff1
...
@@ -22,8 +22,6 @@ module Gitlab
...
@@ -22,8 +22,6 @@ module Gitlab
return
unless
Gitlab
::
ImportExport
.
object_storage?
return
unless
Gitlab
::
ImportExport
.
object_storage?
return
if
uploads
.
empty?
return
if
uploads
.
empty?
mkdir_p
(
uploads_export_path
)
uploads
.
each
do
|
upload_model
|
uploads
.
each
do
|
upload_model
|
next
unless
upload_model
.
file
next
unless
upload_model
.
file
next
if
upload_model
.
upload
.
local?
# Already copied
next
if
upload_model
.
upload
.
local?
# Already copied
...
@@ -51,7 +49,9 @@ module Gitlab
...
@@ -51,7 +49,9 @@ module Gitlab
end
end
def
download_and_copy
(
upload
)
def
download_and_copy
(
upload
)
upload_path
=
File
.
join
(
uploads_export_path
,
upload
.
filename
)
mkdir_p
(
File
.
join
(
uploads_export_path
,
upload
.
secret
))
upload_path
=
File
.
join
(
uploads_export_path
,
upload
.
secret
,
upload
.
filename
)
File
.
open
(
upload_path
,
'w'
)
do
|
file
|
File
.
open
(
upload_path
,
'w'
)
do
|
file
|
IO
.
copy_stream
(
URI
.
parse
(
upload
.
file
.
url
).
open
,
file
)
IO
.
copy_stream
(
URI
.
parse
(
upload
.
file
.
url
).
open
,
file
)
...
...
spec/lib/gitlab/import_export/uploads_manager_spec.rb
View file @
874a4ff1
...
@@ -4,6 +4,7 @@ describe Gitlab::ImportExport::UploadsManager do
...
@@ -4,6 +4,7 @@ describe Gitlab::ImportExport::UploadsManager do
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:exported_file_path
)
{
"
#{
shared
.
export_path
}
/uploads/
#{
upload
.
secret
}
/
#{
File
.
basename
(
upload
.
path
)
}
"
}
subject
(
:manager
)
{
described_class
.
new
(
project:
project
,
shared:
shared
)
}
subject
(
:manager
)
{
described_class
.
new
(
project:
project
,
shared:
shared
)
}
...
@@ -18,7 +19,7 @@ describe Gitlab::ImportExport::UploadsManager do
...
@@ -18,7 +19,7 @@ describe Gitlab::ImportExport::UploadsManager do
describe
'#copy'
do
describe
'#copy'
do
context
'when the project has uploads locally stored'
do
context
'when the project has uploads locally stored'
do
let
(
:upload
)
{
create
(
:upload
)
}
let
(
:upload
)
{
create
(
:upload
,
:issuable_upload
,
:with_file
,
model:
project
)
}
before
do
before
do
project
.
uploads
<<
upload
project
.
uploads
<<
upload
...
@@ -33,7 +34,27 @@ describe Gitlab::ImportExport::UploadsManager do
...
@@ -33,7 +34,27 @@ describe Gitlab::ImportExport::UploadsManager do
it
'copies the file in the correct location when there is an upload'
do
it
'copies the file in the correct location when there is an upload'
do
manager
.
copy
manager
.
copy
expect
(
File
).
to
exist
(
"
#{
shared
.
export_path
}
/uploads/
#{
File
.
basename
(
upload
.
path
)
}
"
)
expect
(
File
).
to
exist
(
exported_file_path
)
end
end
context
'using object storage'
do
let!
(
:upload
)
{
create
(
:upload
,
:issuable_upload
,
:object_storage
,
model:
project
)
}
before
do
stub_feature_flags
(
import_export_object_storage:
true
)
stub_uploads_object_storage
(
FileUploader
)
end
it
'downloads the file to include in an archive'
do
fake_uri
=
double
expect
(
fake_uri
).
to
receive
(
:open
).
and_return
(
StringIO
.
new
(
'File content'
))
expect
(
URI
).
to
receive
(
:parse
).
and_return
(
fake_uri
)
manager
.
copy
expect
(
File
.
read
(
exported_file_path
)).
to
eq
(
'File content'
)
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