If the user explicitly shares a file, remove it form the negative tree. #26

pull/34/head
Zlatin Balevsky 2019-11-13 22:00:10 +00:00
parent 5fa2f2753c
commit 114bc06dbb
2 changed files with 6 additions and 3 deletions

View File

@ -7,7 +7,7 @@ class FileTree {
private final TreeNode root = new TreeNode()
private final Map<File, TreeNode> fileToNode = new ConcurrentHashMap<>()
void add(File file) {
synchronized void add(File file) {
List<File> 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

View File

@ -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))
}
}