mirror of https://github.com/zlatinb/muwire
If the user explicitly shares a file, remove it form the negative tree. #26
parent
5fa2f2753c
commit
114bc06dbb
|
@ -7,7 +7,7 @@ class FileTree {
|
||||||
private final TreeNode root = new TreeNode()
|
private final TreeNode root = new TreeNode()
|
||||||
private final Map<File, TreeNode> fileToNode = new ConcurrentHashMap<>()
|
private final Map<File, TreeNode> fileToNode = new ConcurrentHashMap<>()
|
||||||
|
|
||||||
void add(File file) {
|
synchronized void add(File file) {
|
||||||
List<File> path = new ArrayList<>()
|
List<File> path = new ArrayList<>()
|
||||||
path.add(file)
|
path.add(file)
|
||||||
while (file.getParentFile() != null) {
|
while (file.getParentFile() != null) {
|
||||||
|
@ -31,7 +31,7 @@ class FileTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean remove(File file) {
|
synchronized boolean remove(File file) {
|
||||||
TreeNode node = fileToNode.remove(file)
|
TreeNode node = fileToNode.remove(file)
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -511,7 +511,9 @@ class MainFrameView {
|
||||||
public boolean importData(TransferHandler.TransferSupport support) {
|
public boolean importData(TransferHandler.TransferSupport support) {
|
||||||
def files = support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)
|
def files = support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)
|
||||||
files.each {
|
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()
|
showUploadsWindow.call()
|
||||||
true
|
true
|
||||||
|
@ -1106,6 +1108,7 @@ class MainFrameView {
|
||||||
if (rv == JFileChooser.APPROVE_OPTION) {
|
if (rv == JFileChooser.APPROVE_OPTION) {
|
||||||
chooser.getSelectedFiles().each {
|
chooser.getSelectedFiles().each {
|
||||||
File canonical = it.getCanonicalFile()
|
File canonical = it.getCanonicalFile()
|
||||||
|
model.core.fileManager.negativeTree.remove(canonical)
|
||||||
model.core.eventBus.publish(new FileSharedEvent(file : canonical))
|
model.core.eventBus.publish(new FileSharedEvent(file : canonical))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue