Patchwork [STABLE] inifinitepush: fix filebundlestore to close file

login
register
mail settings
Submitter Yuya Nishihara
Date April 19, 2018, 11:29 a.m.
Message ID <3866a9af240cc01e5eab.1524137393@mimosa>
Download mbox | patch
Permalink /patch/31200/
State Accepted
Headers show

Comments

Yuya Nishihara - April 19, 2018, 11:29 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1524136953 -32400
#      Thu Apr 19 20:22:33 2018 +0900
# Branch stable
# Node ID 3866a9af240cc01e5eab12ffeac668f61cfa2a13
# Parent  8ba1c6dab49f5665dc687000f149eb530a1079cf
inifinitepush: fix filebundlestore to close file

Patch

diff --git a/hgext/infinitepush/store.py b/hgext/infinitepush/store.py
--- a/hgext/infinitepush/store.py
+++ b/hgext/infinitepush/store.py
@@ -86,12 +86,11 @@  class filebundlestore(object):
 
     def read(self, key):
         try:
-            f = open(self._filepath(key), 'rb')
+            with open(self._filepath(key), 'rb') as f:
+                return f.read()
         except IOError:
             return None
 
-        return f.read()
-
 class externalbundlestore(abstractbundlestore):
     def __init__(self, put_binary, put_args, get_binary, get_args):
         """