Page 1 of 1

Atomically move torrent data to download dir

Posted: Mon Jan 28, 2013 7:01 am
by hschmidt
Hi, is there a reason why Transmission moves every file in the torrent's data directory individually from the incomplete to the download directory? I have a utility that monitors the the download directory for completed torrents using inotfy(7) but I can't get it to work reliably since the torrent data isn't moved atomically, but file by file.

There is nothing wrong with the way Transmission does it but it would be nice if the data directory were being moved atomically if old and new location are on the same file system. At the very least, it would be more efficient. Interestingly, tr_moveFile() in util.c already detects if source and destination are in the same filesystem and uses rename() in that case. I'd be happy to submit a patch but I fear that there is a particular reason as to why setLocation() in torrent.c doesn't apply that same optimization to the entire data directory.

Re: Atomically move torrent data to download dir

Posted: Wed Feb 06, 2013 2:36 pm
by Jordan
hschmidt, that code moves the contents file-by-file, rather than all in a batch, to handle the edge cases where two torrents would have the same top-level directory s.t. their files would overlap in the same subdirectory.

However, that call to tr_torrentDeleteLocalData() on the old directory at the end makes me wonder how well that works -- and, since nobody's reporting it, whether or not that edge case is actually important to many people.

Please make your patch for trunk, as libtransmission's been refactored a little bit since 2.7x.