Skip to content

Commit

Permalink
Delayed Completion Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pyroscope committed Aug 20, 2017
1 parent 560581c commit a481116
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/examples/event.download.finished_delayed.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#############################################################################
# Add a "finished_delayed" event
#
# See https://github.com/rakshasa/rtorrent/issues/547
#############################################################################

# Delay in seconds
method.insert.value = event.download.finished_delayed.interval, 600

# Add persistent view (queue holding delayed items)
view.add = finished_delayed
view.persistent = finished_delayed

# Add new event for delayed completion handling
method.insert = event.download.finished_delayed, multi|rlookup|static
method.set_key = event.download.finished, !add_to_finished_delayed, \
"d.views.push_back_unique = finished_delayed ; \
view.filter_download = finished_delayed"
method.set_key = event.download.finished_delayed, !remove_from_finished_delayed, \
"d.views.remove = finished_delayed ; \
view.filter_download = finished_delayed"

# Call new event for items that passed the delay interval
schedule2 = event.download.finished_delayed, 60, 60, \
((d.multicall2, finished_delayed, \
"branch=\"elapsed.greater=(d.timestamp.finished),(event.download.finished_delayed.interval)\", \
event.download.finished_delayed="))

# For debugging…
method.set_key = event.download.finished_delayed, !debug, \
"print = \"DELAYED FINISH after \", (convert.elapsed_time, (d.timestamp.finished)), \
\" of \", (d.name)"
21 changes: 21 additions & 0 deletions docs/use-cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ including the above config snippet.
.. _`completion-path.sh`: https://github.com/rtorrent-community/rtorrent-docs/blob/master/docs/examples/completion-path.sh


.. _event.download.finished_delayed:

Delayed Completion Handling
---------------------------

The following config snippet defines a new ``event.download.finished_delayed`` trigger
that works like the normal finished event, but only fires after a customizable delay.

One use-case for such a thing is to move a download from fast storage (RAM disk, SSD)
to slow storage (HDD) for permanent seeding, after the initial rush in a swarm is over.

The following is the config you need to add to a ``config.d/event.download.finished_delayed.rc`` file
(see :ref:`drop-in-config` on how to get a ``config.d`` directory),
or else to your normal ``rtorrent.rc`` file:

.. literalinclude:: examples/event.download.finished_delayed.rc
:language: ini

The last command adding a ``!debug`` handler can be left out, if you want less verbosity.


Set a Download to “Seed Only”
-----------------------------

Expand Down

0 comments on commit a481116

Please sign in to comment.