Moving Transmission-daemon’s files

I first heard of BitTorrent when Mandriva began encouraging its users to download the Linux distribution’s ISO files using BitTorrent, in order to lessen the load on Mandriva’s servers. Yet it is somewhat recently that I began to actually use it. To this end, I installed the transmission-daemon package from Debian.

Lacking experience and expectations regarding the BitTorrent protocol and Transmission, I simply set the latter up with /data/partial as the directory for the temporary files, and /data/share as the final destination for completed downloads; the latter is the place where I put all my shared files (LAN-wide). I thought that I would move the completed downloads to the right subdirectories as they appear…

There is a problem with this configuration: the BitTorrent protocol expects you to share (“seed”) what you have downloaded from other users, thus preventing you from removing the files once you have them. Of course, I wish to keep these files, but elsewhere!

Keeping the files elsewhere is not a problem: for each completed download, I just have to create a hard link in the right subdirectory; I may even rename the hard link. My problem is removing the downloaded files from their default place at the root of /data/share, since this would disrupt the operation of Transmission. And that place has become a mess…

I’ve read that the desktop version of Transmission has a “move files” feature. Or maybe it is a feature of a newer version; unfortunately, Debian-stable’s Transmission is ages and a libc upgrade away from this newer version… So I found another way to deal with the issue.

My goal is to have all my BitTorrent downloads in /data/share/_new from now on. The first step is of course to change the default path in Transmission’s configuration. Then there “only” remains to alter the location of already-downloaded files. I will achieve the latter by altering Transmission’s binary data files, to change /data/share to /data/s_new (same string length), with /data/s_new being a symbolic link to /data/share/_new ;-)

Information about torrents’ paths is kept is “resume” files in /var/lib/transmission-daemon/info/resume. So I head my shell to this place, I stop Transmission, and I type:

ls -1 *.resume | while read r; do
strings "$r" | grep /share | grep -vq /_new && echo "$r"

This gives me the list of “resume” files that have to be altered; I will do this with the hexedit command-line tool. [Ctrl]+[S] is for searching, [Tab] is for switching from the hexadecimal columns to the ASCII columns, [Ctrl]+[X] is for saving and exiting, and [←] and [→] work as expected. So, for each of the files given by the command above (FILE bellow), I type these keys:

hexedit FILE[ENTER]

Then I actually move the files and directories corresponding to each of these altered “resume” files to their new location in /data/share/_new, and I ensure that the /data/s_new symbolic link is correctly created. That’s all, Transmission can be restarted.

After a while, I delete the torrents which have been fairly seeded; I cannot keep them all! Thus, eventually, old torrents will disappear, and the /data/s_new symbolic link won’t be needed any more.

Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

La discussion continue ailleurs

URL de rétrolien :

Fil des commentaires de ce billet