Page 1 of 1

Move finished torrent without actual download

Posted: Wed May 09, 2012 2:10 pm
by Lundberg
Hello,

I have a web application that takes care of file upload and places the uploaded file in a directory on the same machine deluged is running on. During this upload my
plugin (LobberCore) adds the torrent to deluged and it starts to "download" but the file is already in the download directory. My thought was that the data then should be moved to storage directory and the torrent seeded from there.

But then this bit of code in torrentmanager.py ruins my plan:

Code: Select all

    def on_alert_torrent_finished(self, alert):
        *snip*
        # Get the total_download and if it's 0, do not move.. It's likely
        # that the torrent wasn't downloaded, but just added.
        total_download = torrent.get_status(["total_payload_download"])["total_payload_download"]

        # Move completed download to completed folder if needed
        if not torrent.is_finished and total_download:
            move_path = None

            if torrent.options["move_completed"]:
                move_path = torrent.options["move_completed_path"]
                if torrent.options["download_location"] != move_path:
                    torrent.move_storage(move_path)

            component.get("EventManager").emit(TorrentFinishedEvent(torrent_id))

        torrent.is_finished = True
        torrent.update_state()
         *snip*
What this means for me is that I get a torrent in finished state but it will never be moved.

I would like an explanation to the comment "Get the total_download and if it's 0, do not move.. It's likely that the torrent wasn't downloaded, but just added.". Does that mean that libtorrent sends an finished alert when a torrent is added but not yet finished downloading?

Thank you for a great torrent client.

Re: Move finished torrent without actual download

Posted: Wed May 09, 2012 6:22 pm
by Cas
Lundberg wrote:I would like an explanation to the comment "Get the total_download and if it's 0, do not move.. It's likely that the torrent wasn't downloaded, but just added.". Does that mean that libtorrent sends an finished alert when a torrent is added but not yet finished downloading?
A finished alert will be produced by libtorrent on a complete torrent. If you have the complete data already, so are seeding a torrent, the torrentmanager code assumes that since it requires no more downloading the data is in the storage directory. When file uploading from web app why not put the data into your storage directory?

Re: Move finished torrent without actual download

Posted: Thu May 10, 2012 8:10 am
by Lundberg
Cas wrote:A finished alert will be produced by libtorrent on a complete torrent.
Ok, then I think it still should honor the move_completed and move_completed_path options but I can do it the other way around, as you suggested.

Thank you!