Patchwork D7957: lfs: explicitly close the file handle for the blob being uploaded

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

Comments

phabricator - Jan. 22, 2020, 3:59 p.m.
Closed by commit rHGfad1db080e99: lfs: explicitly close the file handle for the blob being uploaded (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/D7957?vs=19491&id=19507

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

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

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
@@ -110,11 +110,12 @@ 
     def read(self, size):
         if self._fp is None:
             return b''
-        data = self._fp.read(size)
-        if not data:
+        return self._fp.read(size)
+
+    def close(self):
+        if self._fp is not None:
             self._fp.close()
             self._fp = None
-        return data
 
 
 class local(object):
@@ -539,6 +540,9 @@ 
             raise LfsRemoteError(
                 _(b'LFS error: %s') % _urlerrorreason(ex), hint=hint
             )
+        finally:
+            if request.data:
+                request.data.close()
 
     def _batch(self, pointers, localstore, action):
         if action not in [b'upload', b'download']: