From 5e0dcb73f0d325ed2d1aade8c90e7887c64f5630 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 3 Dec 2011 02:33:42 +0000 Subject: [PATCH] * synchronize CLI calls --- .../filebot/cli/ScriptShell.lib.groovy | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index c349009d..b64226f7 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -95,31 +95,45 @@ List.metaClass.watch = { c -> getWatchService(c, delegate) } // CLI bindings def rename(args) { args = _defaults(args) - _guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.lang, args.strict) } + synchronized (_cli) { + _guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.lang, args.strict) } + } } -def getSubtitles(args) { args = _defaults(args) - _guarded { _cli.getSubtitles(_files(args), args.query, args.lang, args.output, args.encoding, args.strict) } +def getSubtitles(args) { args = _defaults(args) + synchronized (_cli) { + _guarded { _cli.getSubtitles(_files(args), args.query, args.lang, args.output, args.encoding, args.strict) } + } } -def getMissingSubtitles(args) { args = _defaults(args) - _guarded { _cli.getMissingSubtitles(_files(args), args.query, args.lang, args.output, args.encoding, args.strict) } +def getMissingSubtitles(args) { args = _defaults(args) + synchronized (_cli) { + _guarded { _cli.getMissingSubtitles(_files(args), args.query, args.lang, args.output, args.encoding, args.strict) } + } } def check(args) { - _guarded { _cli.check(_files(args)) } + synchronized (_cli) { + _guarded { _cli.check(_files(args)) } + } } def compute(args) { args = _defaults(args) - _guarded { _cli.compute(_files(args), args.output, args.encoding) } + synchronized (_cli) { + _guarded { _cli.compute(_files(args), args.output, args.encoding) } + } } def fetchEpisodeList(args) { args = _defaults(args) - _guarded { _cli.fetchEpisodeList(args.query, args.format, args.db, args.lang) } + synchronized (_cli) { + _guarded { _cli.fetchEpisodeList(args.query, args.format, args.db, args.lang) } + } } def getMediaInfo(args) { args = _defaults(args) - _guarded { _cli.getMediaInfo(args.file, args.format) } + synchronized (_cli) { + _guarded { _cli.getMediaInfo(args.file, args.format) } + } } @@ -153,4 +167,4 @@ def _defaults(args) { /** * Catch and log exceptions thrown by the closure */ -this.metaClass._guarded = { c -> try { return c() } catch (e) { _log.severe(e.getMessage()); return null }} +this.metaClass._guarded = { c -> try { return c.call() } catch (e) { _log.severe(e.getMessage()); return null }}