diff --git a/core/src/main/groovy/com/muwire/core/files/FileTree.groovy b/core/src/main/groovy/com/muwire/core/files/FileTree.groovy index 9f2194f0..4d2f83a3 100644 --- a/core/src/main/groovy/com/muwire/core/files/FileTree.groovy +++ b/core/src/main/groovy/com/muwire/core/files/FileTree.groovy @@ -7,7 +7,7 @@ class FileTree { private final TreeNode root = new TreeNode() private final Map fileToNode = new ConcurrentHashMap<>() - void add(File file) { + synchronized void add(File file) { List path = new ArrayList<>() path.add(file) while (file.getParentFile() != null) { @@ -31,7 +31,7 @@ class FileTree { } } - boolean remove(File file) { + synchronized boolean remove(File file) { TreeNode node = fileToNode.remove(file) if (node == null) { return false diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 4bec47e2..cd6f7add 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -511,7 +511,9 @@ class MainFrameView { public boolean importData(TransferHandler.TransferSupport support) { def files = support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor) files.each { - model.core.eventBus.publish(new FileSharedEvent(file : it)) + File canonical = it.getCanonicalFile() + model.core.fileManager.negativeTree.remove(canonical) + model.core.eventBus.publish(new FileSharedEvent(file : canonical)) } showUploadsWindow.call() true @@ -1106,6 +1108,7 @@ class MainFrameView { if (rv == JFileChooser.APPROVE_OPTION) { chooser.getSelectedFiles().each { File canonical = it.getCanonicalFile() + model.core.fileManager.negativeTree.remove(canonical) model.core.eventBus.publish(new FileSharedEvent(file : canonical)) } }