LFS download service not skipping body fragment on redirect
Summary
When mirroring an external repository using object storage (Gitlab + S3), I get a 'size mismatch' error.
This is due to the body of the redirection not being skipped in this code: https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/services/projects/lfs_pointers/lfs_download_service.rb#L63
Possible fixes
Replace this code:
def download_and_save_file!(file)
digester = Digest::SHA256.new
fetch_file do |fragment|
digester << fragment
file.write(fragment)
raise_size_error! if file.size > lfs_size
end
with
def download_and_save_file!(file)
digester = Digest::SHA256.new
fetch_file do |fragment|
if ! [301, 302].include?(fragment.code)
digester << fragment
file.write(fragment)
end
raise_size_error! if file.size > lfs_size
end