Atomically move torrent data to download dir
Posted: Mon Jan 28, 2013 7:01 am
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.
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.