Skip to content

Commit bbd090b

Browse files
committed
close StreamChunks on file release
Added release method for StreamedResponseCache for closing unnecessary file chunks. Should prevent excessive number of open sockets (concerns #98).
1 parent bed5abf commit bbd090b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

acd_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
for plug_mod in iter_entry_points(group='acdcli.plugins', name=None):
3434
__import__(plug_mod.module_name)
3535

36-
__version__ = '0.3.0a2'
36+
__version__ = '0.3.0a3'
3737
_app_name = 'acd_cli'
3838

3939
logger = logging.getLogger(_app_name)

acdcli/fuse.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ def get(self, id, offset, length, total):
8888
return chunk.get(length)
8989

9090
def clear(self):
91-
for chunk in self.chunks():
91+
for chunk in self.chunks:
9292
try:
9393
chunk.close()
9494
except:
9595
pass
96+
self.chunks.clear()
9697

9798
files = defaultdict(File)
9899

@@ -104,6 +105,10 @@ def get(cls, id, offset, length, total):
104105
def invalidate(cls):
105106
pass
106107

108+
@classmethod
109+
def release(cls, id):
110+
cls.files[id].clear()
111+
107112

108113
class ACDFuse(Operations):
109114
def __init__(self):
@@ -309,6 +314,9 @@ def open(self, path, flags):
309314
def release(self, path, fh):
310315
logger.debug('release %s, %d' % (path, fh))
311316

317+
node, _ = query.resolve(path, trash=False)
318+
StreamedResponseCache.release(node.id)
319+
312320
def utimens(self, path, times=None):
313321
logger.debug('utimens %s' % path)
314322

0 commit comments

Comments
 (0)