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
8eb7faa3
Commit
8eb7faa3
authored
Oct 19, 2021
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '328484-import-use-gitlab-http' into 'master'"
This reverts merge request !72465
parent
b334f0d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
57 deletions
+3
-57
lib/gitlab/import_export/command_line_util.rb
lib/gitlab/import_export/command_line_util.rb
+3
-13
spec/lib/gitlab/import_export/command_line_util_spec.rb
spec/lib/gitlab/import_export/command_line_util_spec.rb
+0
-44
No files found.
lib/gitlab/import_export/command_line_util.rb
View file @
8eb7faa3
...
...
@@ -56,20 +56,10 @@ module Gitlab
end
def
download
(
url
,
upload_path
)
File
.
open
(
upload_path
,
'wb'
)
do
|
file
|
Gitlab
::
HTTP
.
get
(
url
,
stream_body:
true
)
do
|
fragment
|
if
[
301
,
302
,
307
].
include?
(
fragment
.
code
)
Gitlab
::
Import
::
Logger
.
warn
(
message:
"received redirect fragment"
,
fragment_code:
fragment
.
code
)
elsif
fragment
.
code
==
200
file
.
write
(
fragment
)
else
raise
Gitlab
::
ImportExport
::
Error
,
"unsupported response downloading fragment
#{
fragment
.
code
}
"
end
end
File
.
open
(
upload_path
,
'w'
)
do
|
file
|
# Download (stream) file from the uploader's location
IO
.
copy_stream
(
URI
.
parse
(
url
).
open
,
file
)
end
rescue
StandardError
=>
e
@shared
.
error
(
e
)
# rubocop:disable Gitlab/ModuleWithInstanceVariables
raise
e
end
def
tar_with_options
(
archive
:,
dir
:,
options
:)
...
...
spec/lib/gitlab/import_export/command_line_util_spec.rb
View file @
8eb7faa3
...
...
@@ -17,10 +17,6 @@ RSpec.describe Gitlab::ImportExport::CommandLineUtil do
def
initialize
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
nil
)
end
def
download
(
url
,
upload_path
)
super
(
url
,
upload_path
)
end
end
.
new
end
...
...
@@ -105,44 +101,4 @@ RSpec.describe Gitlab::ImportExport::CommandLineUtil do
end
end
end
describe
'#download'
do
before
do
stub_request
(
:get
,
loc
)
.
to_return
(
status:
200
,
body:
content
)
end
context
'a non-localhost uri'
do
let
(
:loc
)
{
'https://gitlab.com'
}
let
(
:content
)
{
File
.
open
(
'spec/fixtures/rails_sample.tif'
)
}
it
'gets the contents'
do
Tempfile
.
create
(
"foo"
)
do
|
f
|
subject
.
download
(
loc
,
f
.
path
)
expect
(
f
.
read
).
to
eq
(
File
.
open
(
'spec/fixtures/rails_sample.tif'
).
read
)
end
end
it
'streams the contents'
do
expect
(
Gitlab
::
HTTP
).
to
receive
(
:get
).
with
(
loc
,
hash_including
(
stream_body:
true
))
Tempfile
.
create
(
"foo"
)
do
|
f
|
subject
.
download
(
loc
,
f
.
path
)
end
end
end
context
'a localhost uri'
do
let
(
:loc
)
{
'https://localhost:8081/foo/bar'
}
let
(
:content
)
{
'foo'
}
it
'throws a blocked url error'
do
Tempfile
.
create
(
"foo"
)
do
|
f
|
expect
{
subject
.
download
(
loc
,
f
.
path
)
}.
to
raise_error
(
Gitlab
::
HTTP
::
BlockedUrlError
)
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