hgext/largefiles/remotestore.py
changeset 30142 3dcaf1c4e90d
parent 29313 0ccab84f9630
child 30180 736f92c44656
--- a/hgext/largefiles/remotestore.py	Sat Oct 08 00:59:40 2016 +0200
+++ b/hgext/largefiles/remotestore.py	Sat Oct 08 00:59:41 2016 +0200
@@ -45,17 +45,13 @@
 
     def sendfile(self, filename, hash):
         self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash))
-        fd = None
         try:
-            fd = lfutil.httpsendfile(self.ui, filename)
-            return self._put(hash, fd)
+            with lfutil.httpsendfile(self.ui, filename) as fd:
+                return self._put(hash, fd)
         except IOError as e:
             raise error.Abort(
                 _('remotestore: could not open file %s: %s')
                 % (filename, str(e)))
-        finally:
-            if fd:
-                fd.close()
 
     def _getfile(self, tmpfile, filename, hash):
         try: