From 5cb89149d42fc9c7f18a789765c2198702218f64 Mon Sep 17 00:00:00 2001 From: Anthony Raymond Date: Fri, 26 May 2023 11:08:15 +0200 Subject: [PATCH] Fix TorrentFileWatcher not returning exception when directory does not exists --- .../joal/core/torrent/watcher/TorrentFileWatcher.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/araymond/joal/core/torrent/watcher/TorrentFileWatcher.java b/src/main/java/org/araymond/joal/core/torrent/watcher/TorrentFileWatcher.java index a9c8407..9fe1ae9 100644 --- a/src/main/java/org/araymond/joal/core/torrent/watcher/TorrentFileWatcher.java +++ b/src/main/java/org/araymond/joal/core/torrent/watcher/TorrentFileWatcher.java @@ -10,6 +10,7 @@ import org.apache.commons.io.monitor.FileAlterationMonitor; import org.apache.commons.io.monitor.FileAlterationObserver; import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; import static java.nio.file.Files.isDirectory; @@ -54,6 +55,9 @@ class TorrentFileWatcher { void start() { try { + if (!this.monitoredFolder.exists()) { + throw new IllegalArgumentException(String.format("Torrent directory [%s] does not exist", monitoredFolder)); + } this.monitor.start(); // Trigger event for already present files: FileUtils.listFiles(this.monitoredFolder, TORRENT_FILE_FILTER, null)