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
d112e364
Commit
d112e364
authored
Jul 19, 2021
by
Robert May
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'master'
Skip LFS fragment on redirect See merge request gitlab-org/gitlab!65751
parents
c6dd3a0a
559e7a5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
app/services/projects/lfs_pointers/lfs_download_service.rb
app/services/projects/lfs_pointers/lfs_download_service.rb
+8
-2
spec/services/projects/lfs_pointers/lfs_download_service_spec.rb
...rvices/projects/lfs_pointers/lfs_download_service_spec.rb
+20
-0
No files found.
app/services/projects/lfs_pointers/lfs_download_service.rb
View file @
d112e364
...
@@ -61,8 +61,10 @@ module Projects
...
@@ -61,8 +61,10 @@ module Projects
def
download_and_save_file!
(
file
)
def
download_and_save_file!
(
file
)
digester
=
Digest
::
SHA256
.
new
digester
=
Digest
::
SHA256
.
new
fetch_file
do
|
fragment
|
fetch_file
do
|
fragment
|
digester
<<
fragment
if
digest_fragment?
(
fragment
)
file
.
write
(
fragment
)
digester
<<
fragment
file
.
write
(
fragment
)
end
raise_size_error!
if
file
.
size
>
lfs_size
raise_size_error!
if
file
.
size
>
lfs_size
end
end
...
@@ -71,6 +73,10 @@ module Projects
...
@@ -71,6 +73,10 @@ module Projects
raise_oid_error!
if
digester
.
hexdigest
!=
lfs_oid
raise_oid_error!
if
digester
.
hexdigest
!=
lfs_oid
end
end
def
digest_fragment?
(
fragment
)
fragment
.
http_response
.
is_a?
(
Net
::
HTTPSuccess
)
end
def
download_options
def
download_options
http_options
=
{
headers:
lfs_headers
,
stream_body:
true
}
http_options
=
{
headers:
lfs_headers
,
stream_body:
true
}
...
...
spec/services/projects/lfs_pointers/lfs_download_service_spec.rb
View file @
d112e364
...
@@ -106,6 +106,26 @@ RSpec.describe Projects::LfsPointers::LfsDownloadService do
...
@@ -106,6 +106,26 @@ RSpec.describe Projects::LfsPointers::LfsDownloadService do
end
end
end
end
context
'when file download returns a redirect'
do
let
(
:redirect_link
)
{
'http://external-link'
}
before
do
stub_full_request
(
download_link
).
to_return
(
status:
301
,
body:
'You are being redirected'
,
headers:
{
'Location'
=>
redirect_link
}
)
stub_full_request
(
redirect_link
).
to_return
(
body:
lfs_content
)
end
it_behaves_like
'lfs object is created'
it
'correctly stores lfs object'
do
subject
.
execute
new_lfs_object
=
LfsObject
.
first
expect
(
new_lfs_object
).
to
have_attributes
(
oid:
oid
,
size:
size
)
expect
(
File
.
binread
(
new_lfs_object
.
file
.
file
.
file
)).
to
eq
lfs_content
end
end
context
'when downloaded lfs file has a different size'
do
context
'when downloaded lfs file has a different size'
do
let
(
:size
)
{
1
}
let
(
:size
)
{
1
}
...
...
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