Move finished torrent without actual download

Suggestions and discussion of future versions
Post Reply
Lundberg
New User
New User
Posts: 8
Joined: Wed May 09, 2012 1:31 pm

Move finished torrent without actual download

Post 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.
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Move finished torrent without actual download

Post 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?
Lundberg
New User
New User
Posts: 8
Joined: Wed May 09, 2012 1:31 pm

Re: Move finished torrent without actual download

Post 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!
Post Reply