From d33ada22c19bb74b4003e9db5c48a2edf08d1b91 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 25 Jul 2018 14:33:43 +0700 Subject: [PATCH] Better error message if passing in invalid file path (e.g. because of not escaping cmdline args) --- source/net/filebot/License.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/net/filebot/License.java b/source/net/filebot/License.java index 812a5d2a..87e3ff13 100644 --- a/source/net/filebot/License.java +++ b/source/net/filebot/License.java @@ -156,6 +156,11 @@ public class License { public static final MemoizedResource INSTANCE = Resource.lazy(() -> parseLicenseFile(FILE.get())); public static License importLicenseFile(File file) throws Exception { + // require non-empty license file + if (file.length() <= 0) { + throw new FileNotFoundException("License file not found: " + file); + } + // lock memoized resource while validating and setting a new license synchronized (License.INSTANCE) { // check if license file is valid and not expired