Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#3764 closed Enhancement (fixed)

script-torrent-done shouldn't block libtransmission

Reported by: hbt Owned by: charles
Priority: Normal Milestone: 2.20
Component: libtransmission Version: 2.12
Severity: Normal Keywords:
Cc: horrex@…

Description

I want to symlink files within a torrent after downloading is completed. For that, I want to use the following code (snippet):

#!/bin/sh

env > /tmp/test.txt
exec >> /tmp/test.txt 2>&1

TNAME=$(/usr/bin/transmission-remote --auth xxx:xxx -t "$TR_TORRENT_HASH" -if)

The script is executed after downloading, $TR_TORRENT_HASH has the correct value. But somehow "transmission-remote --auth xxx:xxx -t "$TR_TORRENT_HASH" -if" sits there waiting for a timeout. This is the error that is shown afterwards:

transmission-remote: (http://localhost:9091/transmission/rpc) Error

I have no idea why it doesn't work when called via transmission. When I call it from commandline, everything works well:

export TR_TORRENT_HASH=validhash; ./script.sh

FWIW, I don't use incomplete_dir.

Change History (11)

comment:1 Changed 11 years ago by charles

When I try "transmission-remote -t $validhash -if" from the command line I get an error message from failing to parse "-if", but "-i -f" works...

comment:2 Changed 11 years ago by charles

hbt, are you sure this is a transmission bug that needs to be addressed in a ticket like this, rather than an error in the script?

comment:3 Changed 11 years ago by hbt

No, I'm not sure. But you can easily try with a script yourself, ie try to let it list all torrent-files, when it's run from "script-torrent-done". It won't work for me.

BTW, "transmission-remote -if" works on my commandline and is even documented in --help.

comment:4 Changed 11 years ago by gunzip

this issue came up in the forum a few times and solution was to push the whole script to background (&) using curly brackets when invoking transmission-remote:

#!/bin/bash
{
<your script>
} &

otherwise it will hang on the transmission-remote command. you can test by doing something like this:

#!/bin/bash
{
transmission-remote -l >>/tmp/test.log 2>&1
} &

comment:5 Changed 11 years ago by hbt

as gunzip mentioned, this works for me:

#!/bin/sh

{
TNAME=$(/usr/bin/transmission-remote --auth a:b -t "$TR_TORRENT_HASH" -if | grep avi$ | cut -d' ' -f 12 | tail -n 1)
if [ "$TNAME" != "" ]; then
        cd /mnt/storage/movies/Serien
        ln -s ../../torrent/transmission/"$TNAME" .
fi
} &

comment:6 Changed 11 years ago by charles

  • Component changed from Daemon to libtransmission
  • Owner set to charles
  • Status changed from new to assigned
  • Summary changed from transmission-remote doesn't work when invoked from script-torrent-done to script-torrent-done shouldn't block libtransmission
  • Type changed from Bug to Enhancement

comment:7 Changed 11 years ago by charles

  • Milestone changed from None Set to 2.20

comment:8 Changed 11 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

fixed in trunk by r11534.

comment:9 Changed 11 years ago by gunzip

yes it's working now without having to use the { } & thing.

there is one minor regression, which i didn't think was significant enough to re-open the ticket, is the "Calling script ..." line in the log file no longer shows up.

Last edited 11 years ago by gunzip (previous) (diff)

comment:10 Changed 11 years ago by charles

r11535: add the "Calling script..." line back into the logfile.

comment:11 Changed 11 years ago by charles

r11536: handle zombie processes.

Note: See TracTickets for help on using tickets.