Skip to content
Snippets Groups Projects
Commit 2bd652be authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

pullbundle: delay cache file opening

Otherwise we can end-up with a too many file open at the same time.
parent cfdc6f55
No related branches found
No related tags found
No related merge requests found
......@@ -383,10 +383,5 @@
def getcache(repo, bundlename):
cdir = cachedir(repo)
bundlepath = os.path.join(cdir, bundlename)
try:
fd = open(bundlepath, 'rb')
return util.filechunkiter(fd)
except IOError as exc:
if exc.errno != errno.ENOENT:
raise
if not os.path.exists(bundlepath):
return None
......@@ -392,4 +387,13 @@
return None
# delay file opening as much as possible this introduce a small race
# condition if someone remove the file before we actually use it. However
# opening too many file will not work.
def data():
with open(bundlepath, 'rb') as fd:
for chunk in util.filechunkiter(fd):
yield chunk
return data()
def cachewriter(repo, bundlename, stream):
cdir = cachedir(repo)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment