From 0f3c22ddd45341e7381de7130775988774a3bc9b Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 5 Jul 2021 20:44:48 +0100 Subject: [PATCH] fix plugin compilation after recent UnsharedFileEvent changes --- .../java/com/muwire/webui/DownloadedContentServlet.java | 6 +++--- webui/src/main/java/com/muwire/webui/FileManager.java | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/webui/src/main/java/com/muwire/webui/DownloadedContentServlet.java b/webui/src/main/java/com/muwire/webui/DownloadedContentServlet.java index 72cef9df..a5f8d2a0 100644 --- a/webui/src/main/java/com/muwire/webui/DownloadedContentServlet.java +++ b/webui/src/main/java/com/muwire/webui/DownloadedContentServlet.java @@ -33,9 +33,9 @@ public class DownloadedContentServlet extends BasicServlet { public File getResource(String pathInContext) { String infoHashB64 = pathInContext.substring("/DownloadedContent/".length()); InfoHash infoHash = new InfoHash(Base64.decode(infoHashB64)); - Set sharedFiles = core.getFileManager().getRootToFiles().get(infoHash); - if (sharedFiles == null || sharedFiles.isEmpty()) + SharedFile[] sharedFiles = core.getFileManager().getRootToFiles().get(infoHash); + if (sharedFiles == null || sharedFiles.length == 0) return null; - return sharedFiles.iterator().next().getFile(); + return sharedFiles[0].getFile(); } } diff --git a/webui/src/main/java/com/muwire/webui/FileManager.java b/webui/src/main/java/com/muwire/webui/FileManager.java index f9088434..d7c0dff0 100644 --- a/webui/src/main/java/com/muwire/webui/FileManager.java +++ b/webui/src/main/java/com/muwire/webui/FileManager.java @@ -70,7 +70,9 @@ public class FileManager { public void onFileUnsharedEvent(FileUnsharedEvent e) { if (!e.getDeleted()) return; - fileTree.remove(e.getUnsharedFile().getFile()); + for (SharedFile sf : e.getUnsharedFiles()) { + fileTree.remove(sf.getFile()); + } revision++; } @@ -127,7 +129,7 @@ public class FileManager { fileTree.remove(file); revision++; FileUnsharedEvent event = new FileUnsharedEvent(); - event.setUnsharedFile(sf); + event.setUnsharedFiles(new SharedFile[]{sf}); core.getEventBus().publish(event); } else { @@ -139,7 +141,7 @@ public class FileManager { for (SharedFile found : cb.found) { FileUnsharedEvent e = new FileUnsharedEvent(); - e.setUnsharedFile(found); + e.setUnsharedFiles(new SharedFile[]{found}); core.getEventBus().publish(e); }