Patchwork D7959: lfs: move the initialization of the upload request into the try block

login
register
mail settings
Submitter phabricator
Date Jan. 22, 2020, 3:59 p.m.
Message ID <f812adfe5a5b1022c84044a14c4ac2e4@localhost.localdomain>
Download mbox | patch
Permalink /patch/44572/
State Not Applicable
Headers show

Comments

phabricator - Jan. 22, 2020, 3:59 p.m.
Closed by commit rHG71d6f2849dbb: lfs: move the initialization of the upload request into the try block (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7959?vs=19493&id=19509

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7959/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7959

AFFECTED FILES
  hgext/lfs/blobstore.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -490,15 +490,17 @@ 
                     _(b'detected corrupt lfs object: %s') % oid,
                     hint=_(b'run hg verify'),
                 )
-            request.data = lfsuploadfile(localstore.open(oid))
-            request.get_method = lambda: 'PUT'
-            request.add_header('Content-Type', 'application/octet-stream')
-            request.add_header('Content-Length', len(request.data))
 
         for k, v in headers:
             request.add_header(pycompat.strurl(k), pycompat.strurl(v))
 
         try:
+            if action == b'upload':
+                request.data = lfsuploadfile(localstore.open(oid))
+                request.get_method = lambda: 'PUT'
+                request.add_header('Content-Type', 'application/octet-stream')
+                request.add_header('Content-Length', len(request.data))
+
             with contextlib.closing(self.urlopener.open(request)) as res:
                 contentlength = res.info().get(b"content-length")
                 ui = self.ui  # Shorten debug lines