From 9effd7cc6d38138e856e0a14cf901f72513c0677 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 13 Jul 2012 04:58:46 +0000 Subject: [PATCH] * allow local file override for fn:script scheme. Scripts must be saved as "{appdir}/scripts/name.groovy" --- .../filebot/cli/ArgumentProcessor.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java index cb5a1496..f435f114 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java +++ b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java @@ -211,9 +211,22 @@ public class ArgumentProcessor { boolean trusted = trustRemoteScript; // special handling for endorsed online scripts - if (uri.getScheme().endsWith("fn")) { - url = "http://filebot.sourceforge.net/scripts/" + uri.getAuthority() + ".groovy"; - trusted = true; + if (uri.getScheme().equals("fn")) { + String path = "/scripts/" + uri.getAuthority() + ".groovy"; + + // check for local override + File local = new File(getApplicationFolder(), path); + if (local.exists()) { + CLILogger.finest(String.format("[resolve] %s => %s", uri, local)); + return new Script(readAll(new InputStreamReader(new FileInputStream(local), "UTF-8")), true); + } else { + // script repository + URL remote = new URL("http", "filebot.sourceforge.net", path); + CLILogger.finest(String.format("[resolve] %s => %s", uri, remote)); + + url = remote.toString(); + trusted = true; + } } // fetch remote script only if modified