Page 1 of 2

Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 1:33 am
by ben001
Hello,

I am brand new to transmission and am working on getting the daemon configured.

I have compiled version 1.90 on opensolaris snv_132 which worked out well. I ran the gui and configured everything to my liking (with .torrent deletion turned on), watch folder, incomplete directory etc. I did some testing and the .torrent file was being deleted just fine so i copied the configuration to use with the daemon. Everything works except the daemon does not delete the .torrent. From what i see there are no failures logged.

I don't think it is a permissions issue, both the gtk and daemon were run as root.

Has this feature not been implemented in the daemon? I read this http://trac.transmissionbt.com/ticket/1104 which mentions the deletion feature, it is marked as a duplicate of http://trac.transmissionbt.com/ticket/1483 which does not mention anything about deletion.

has anyone got this to work with the daemon or implemented something else to either delete, rename or move loaded .torrent files?

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 2:10 am
by Longinus00
Give this code a whirl and let me know what you think.
http://trac.transmissionbt.com/attachme ... Func2.diff

The relevant ticket: http://trac.transmissionbt.com/ticket/2898

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 3:08 am
by ben001
Works great.

I'll continue to do some more testing to see if anything else broke.

Also you do think renaming of loaded .torrents instead of deletion will be possible at some point?

Thanks for your help

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 3:37 am
by Longinus00
Luckily you're running solaris otherwise inotify would be giving you a headache right now. I wrote code to work around that but I'm still trying to figure out if there's a "better" way of doing it.

If you want to keep a backup of the file, just don't delete it. Does transmission-daemon auto add files from the watch directory when it starts up for you?

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 4:03 am
by ben001
Yes it does.

i had 6 torrents in a watch directory with the daemon stopped, started the daemon and it loaded all 6 torrents then the daemon deleted the .torrents correctly.

also works if i drop torrents into the watch directory while the daemon is running.

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 4:35 am
by Longinus00
This will make the non-inotify behavior the same as inotify's, i.e. it will only add files if they are added while running. This way you can turn deletion off and keep backups of the torrents in the watch directory.

Code: Select all

Index: watch.c
===================================================================
--- watch.c	(revision 10235)
+++ watch.c	(working copy)
@@ -120,12 +120,6 @@
 #define FILE_DELIMITER '\0'
 
 static void
-watchdir_new_impl( dtr_watchdir * w UNUSED )
-{
-    tr_inf( "Using readdir to watch directory \"%s\"", w->dir );
-    w->lastFiles = evbuffer_new( );
-}
-static void
 watchdir_free_impl( dtr_watchdir * w )
 {
     evbuffer_free( w->lastFiles );
@@ -149,6 +143,37 @@
     return in_list;
 }
 static void
+watchdir_new_impl( dtr_watchdir * w UNUSED )
+{
+    struct stat sb;
+    DIR * odir;
+    const char * dirname = w->dir;
+    struct evbuffer * curFiles = evbuffer_new( );
+    tr_inf( "Using readdir to watch directory \"%s\"", w->dir );
+    
+    if( !stat( dirname, &sb )
+        && S_ISDIR( sb.st_mode )
+        && (( odir = opendir( dirname ) ) ) )
+    {
+        struct dirent * d;
+
+        for( d = readdir( odir ); d != NULL; d = readdir( odir ) )
+        {
+            size_t len;
+
+            if( !d->d_name || *d->d_name=='.' ) /* skip dotfiles */
+                continue;
+            if( !strstr( d->d_name, ".torrent" ) ) /* skip non-torrents */
+                continue;
+                
+            len = strlen( d->d_name );
+            add_file_to_list( curFiles, d->d_name, len );
+       }
+    }
+    closedir( odir );
+    w->lastFiles = curFiles;
+}
+static void
 watchdir_update_impl( dtr_watchdir * w )
 {
     struct stat sb;

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 4:51 am
by ben001
root@opensolaris:~/Desktop/transmission-1.90/daemon# patch -p0 < config.diff
patching file watch.c
patch: **** malformed patch at line 8: static void

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 5:14 am
by Longinus00
Apparently it's stripping out all the leading spaces which screws up the diff.

http://pastebin.com/mc933d78

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 6:21 am
by ben001
It still wouldn't patch, i added "@@" on lines 5 and 18.

it compiles but does nothing with the watch directory, doesn't load from it or delete any .torrents from it.

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 6:36 am
by Longinus00
Gah. Next time I'll just gzip the patch and upload it somewhere so these text parsers don't get so overzealous.

Edit settings.json so you have this key:

Code: Select all

"message-level": 3
If you run "transmission-daemon -f" from the command line, do you see it starting the watch directory? Does it have any messages when you add files to the directory?

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 7:13 am
by ben001
sorry pieces of my configuration file were overwritten by settings from a different instance while i was messing around with SMF and init scripts

so it now only loads new .torrent files, not files that were there already. however the gtk loads all .torrents in the watch directory upon loading.

i am not sure what you were trying to do here? maybe you misunderstood my comments above and thought that it was broken?

unless this is the desired behavior...? the gtk and daemon should probably be consistent though.

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 7:31 am
by Longinus00
Well, all I did was make the daemon consistent with itself. When using inotify the daemon also won't load torrents that are already in the watch directory. This is potentially useful as you can make your watch directory your torrent backup directory. Transmission won't try to read all torrents on load so if you turn auto-delete off they'll just stay there. Of course if you prefer the old behavior you can always revert the patch I gave you.

If you want to run both the gtk client and the daemon interchangeably, there's only so much that can be done because they both implement their own watch functions and deletion routines.

Re: Daemon - delete .torrent after loading?

Posted: Sat Feb 20, 2010 7:41 am
by ben001
Interesting, i guess the daemon and gtk are not as closely matched as i would have thought. Must make development rather difficult.

Thanks for your help, I'm glad that i am able to make the switch from utorrent to transmission + automatic without loosing any functionality.

Re: Daemon - delete .torrent after loading?

Posted: Wed Apr 14, 2010 5:27 pm
by jess
Hi guys,

So I'm trying to understand if the deletion of the .torrent file that have been loaded in the Transmission Dameon trough the Watch-Dir currently works ?

Cause I would love to get it works on my Synology Nas.

Please, tell me if I can make it works just with parameters on the settings.json file ?!

Thank You. :D

Re: Daemon - delete .torrent after loading?

Posted: Wed Apr 14, 2010 7:26 pm
by Longinus00
It's in the trunk so you can either build from source or wait for 2.00