Skip to content

Commit

Permalink
[symlink] Support Jinja2 templating for "to" field (Flexget#2032)
Browse files Browse the repository at this point in the history
  • Loading branch information
Łukasz Żarnowiecki authored and cvium committed Dec 19, 2017
1 parent be5f3ab commit ee00c10
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flexget/plugins/output/symlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from flexget import plugin
from flexget.event import event
from flexget.utils.template import render_from_entry, RenderError

log = logging.getLogger('symlink')

Expand Down Expand Up @@ -51,6 +52,12 @@ def on_task_output(self, task, config):
lnkfrom = entry['location']
name = os.path.basename(lnkfrom)
lnkto = os.path.join(config['to'], name)
try:
lnkto = render_from_entry(lnkto, entry)
except RenderError as error:
log.error('Could not render path: %s', lnkto)
entry.fail(str(error))
return
# Hardlinks for dirs will not be failed here
if os.path.exists(lnkto) and (config['link_type'] == 'soft' or os.path.isfile(lnkfrom)):
msg = 'Symlink destination %s already exists' % lnkto
Expand Down

0 comments on commit ee00c10

Please sign in to comment.