From 60ae76fae1d96ac2656ded5594cbb8eea39a9efd Mon Sep 17 00:00:00 2001 From: Bernd Eckenfels Date: Thu, 23 May 2024 17:52:34 +0200 Subject: [PATCH] Reduce the number of dangling FileListeners due to collect operation. --- .../digestarc/DarcFileCollectOperation.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/vfs2provider-digestarc/src/main/java/com/seeburger/vfs2/provider/digestarc/DarcFileCollectOperation.java b/vfs2provider-digestarc/src/main/java/com/seeburger/vfs2/provider/digestarc/DarcFileCollectOperation.java index 3ff1960..5c27675 100644 --- a/vfs2provider-digestarc/src/main/java/com/seeburger/vfs2/provider/digestarc/DarcFileCollectOperation.java +++ b/vfs2provider-digestarc/src/main/java/com/seeburger/vfs2/provider/digestarc/DarcFileCollectOperation.java @@ -48,11 +48,15 @@ public DarcFileCollectOperation(FileObject root) public void process() throws FileSystemException { - if (root instanceof DarcFileObject) + if !(root instanceof DarcFileObject) + { + return; + } + + final DarcFileObject darcFile = (DarcFileObject) root; + final FileObject delegateFile = darcFile.getDelegateFile(); + try { - DarcFileObject darcFile = (DarcFileObject) root; - FileObject delegateFile = darcFile.getDelegateFile(); - filesList.add(delegateFile.getName().getURI()); if (darcFile.getType() == FileType.FOLDER) @@ -70,5 +74,10 @@ public void process() } } } + finally + { + // we can speed up freeing this listener darcFile is no longer needed + delegateFile.getFileSystem().removeListener(delegateFile, darcFile); + } } }