Skip to content
GitLab Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Menu
    Projects Groups Snippets
  • Get a free trial
  • Sign up
  • Login
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 43,157
    • Issues 43,157
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,418
    • Merge requests 1,418
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #335495
Closed
Open
Created Jul 08, 2021 by Pascal Fautré@ScapalContributor

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
Assignee
Assign to
Time tracking