diff --git a/deluge/core/core.py b/deluge/core/core.py
index d7988c19b..60c8d9cdb 100644
--- a/deluge/core/core.py
+++ b/deluge/core/core.py
@@ -562,6 +562,22 @@ class Core(
def export_set_torrent_prioritize_first_last(self, torrent_id, value):
"""Sets a higher priority to the first and last pieces"""
return self.torrents[torrent_id].set_prioritize_first_last(value)
+
+ def export_set_torrent_auto_managed(self, torrent_id, value):
+ """Sets the auto managed flag for queueing purposes"""
+ return self.torrents[torrent_id].set_auto_managed(value)
+
+ def export_set_torrent_stop_at_ratio(self, torrent_id, value):
+ """Sets the torrent to stop at 'stop_ratio'"""
+ return self.torrents[torrent_id].set_stop_at_ratio(value)
+
+ def export_set_torrent_stop_ratio(self, torrent_id, value):
+ """Sets the ratio when to stop a torrent if 'stop_at_ratio' is set"""
+ return self.torrents[torrent_id].set_stop_ratio(value)
+
+ def export_set_torrent_remove_at_ratio(self, torrent_id, value):
+ """Sets the torrent to be removed at 'stop_ratio'"""
+ return self.torrents[torrent_id].set_remove_at_ratio(value)
def export_block_ip_range(self, range):
"""Block an ip range"""
diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
index c0e65225c..3e56d4dcf 100644
--- a/deluge/core/torrent.py
+++ b/deluge/core/torrent.py
@@ -75,7 +75,9 @@ class Torrent:
self.total_uploaded = 0
# Set default auto_managed value
- self.set_auto_managed(options["auto_managed"])
+ self.auto_managed = options["auto_managed"]
+ if not handle.is_paused():
+ handle.auto_managed(self.auto_managed)
# We need to keep track if the torrent is finished in the state to prevent
# some weird things on state load.
@@ -90,6 +92,10 @@ class Torrent:
# Set the filename
self.filename = state.filename
self.is_finished = state.is_finished
+ # Set the per-torrent queue options
+ self.set_stop_at_ratio(state.stop_at_ratio)
+ self.set_stop_ratio(state.stop_ratio)
+ self.set_remove_at_ratio(state.remove_at_ratio)
else:
# Tracker list
self.trackers = []
@@ -160,14 +166,22 @@ class Torrent:
def set_auto_managed(self, auto_managed):
self.auto_managed = auto_managed
- if not self.handle.is_paused():
- self.handle.auto_managed(auto_managed)
-
+ self.handle.auto_managed(auto_managed)
+ self.update_state()
+
+ def set_stop_ratio(self, stop_ratio):
+ self.stop_ratio = stop_ratio
+
+ def set_stop_at_ratio(self, stop_at_ratio):
+ self.stop_at_ratio = stop_at_ratio
+
+ def set_remove_at_ratio(self, remove_at_ratio):
+ self.remove_at_ratio = remove_at_ratio
+
def set_file_priorities(self, file_priorities):
log.debug("setting %s's file priorities: %s", self.torrent_id, file_priorities)
self.handle.prioritize_files(file_priorities)
- # XXX: I don't think this is needed anymore since we have torrent_resumed alert
if 0 in self.file_priorities:
# We have previously marked a file 'Do Not Download'
# Check to see if we have changed any 0's to >0 and change state accordingly
@@ -390,7 +404,10 @@ class Torrent:
"active_time": self.status.active_time,
"seeding_time": self.status.seeding_time,
"seed_rank": self.status.seed_rank,
- "is_auto_managed": self.auto_managed
+ "is_auto_managed": self.auto_managed,
+ "stop_ratio": self.stop_ratio,
+ "stop_at_ratio": self.stop_at_ratio,
+ "remove_at_ratio": self.remove_at_ratio
}
fns = {
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index c2162a50b..01844b3ad 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -65,7 +65,10 @@ class TorrentState:
file_priorities=None,
queue=None,
auto_managed=None,
- is_finished=False
+ is_finished=False,
+ stop_ratio=2.00,
+ stop_at_ratio=False,
+ remove_at_ratio=True
):
self.torrent_id = torrent_id
self.filename = filename
@@ -85,6 +88,9 @@ class TorrentState:
self.prioritize_first_last = prioritize_first_last
self.file_priorities = file_priorities
self.auto_managed = auto_managed
+ self.stop_ratio = stop_ratio
+ self.stop_at_ratio = stop_at_ratio
+ self.remove_at_ratio = remove_at_ratio
class TorrentManagerState:
def __init__(self):
@@ -158,13 +164,14 @@ class TorrentManager(component.Component):
self.alerts.handle_alerts(True)
def update(self):
- if self.config["stop_seed_at_ratio"]:
- for torrent in self.torrents:
- if torrent.get_ratio() >= self.config["stop_seed_ratio"] and torrent.is_finished:
+ for torrent in self.torrents:
+ if self.config["stop_seed_at_ratio"] or torrent.stop_at_ratio:
+ if (torrent.get_ratio() >= self.config["stop_seed_ratio"] or\
+ torrent.get_ratio() > torrent.stop_ratio) and torrent.is_finished:
torrent.pause()
- if self.config["remove_seed_at_ratio"]:
+ if self.config["remove_seed_at_ratio"] or torrent.remove_at_ratio:
self.remove(torrent.torrent_id)
-
+
def __getitem__(self, torrent_id):
"""Return the Torrent with torrent_id"""
return self.torrents[torrent_id]
@@ -504,7 +511,10 @@ class TorrentManager(component.Component):
torrent.file_priorities,
torrent.get_queue_position(),
torrent.auto_managed,
- torrent.is_finished
+ torrent.is_finished,
+ torrent.stop_ratio,
+ torrent.stop_at_ratio,
+ torrent.remove_at_ratio
)
state.torrents.append(torrent_state)
diff --git a/deluge/ui/client.py b/deluge/ui/client.py
index e2c000882..aa76fe44a 100644
--- a/deluge/ui/client.py
+++ b/deluge/ui/client.py
@@ -164,7 +164,9 @@ class BaseClient(object):
"block_ip_range", "remove_torrent", "pause_torrent", "move_storage",
"resume_torrent", "force_reannounce", "force_recheck",
"deregister_client", "register_client", "add_torrent_file",
- "set_torrent_prioritize_first_last"]
+ "set_torrent_prioritize_first_last", "set_torrent_auto_managed",
+ "set_torrent_stop_ratio", "set_torrent_stop_at_ratio",
+ "set_torrent_remove_at_ratio"]
def __init__(self):
self.core = _core
diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade
index 4f1ecab98..6be5f9d80 100644
--- a/deluge/ui/gtkui/glade/main_window.glade
+++ b/deluge/ui/gtkui/glade/main_window.glade
@@ -646,191 +646,276 @@
-
+
True
- 0
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- 0
-
-
- 3
- 4
- GTK_FILL
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- 5
-
-
- True
- 0
- <b>Downloaded:</b>
- True
-
-
-
-
- GTK_FILL
-
-
-
-
- True
- 5
-
-
- True
- 0
- <b>Uploaded:</b>
- True
-
-
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- 5
-
-
- True
- 0
- <b>Share Ratio:</b>
- True
-
-
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
- True
- 5
-
-
- True
- 0
- <b>Next Announce:</b>
- True
-
-
+ 5
+ 6
3
4
GTK_FILL
-
+
True
- 15
- 5
-
-
- True
- 0
- <b>Speed:</b>
- True
-
-
+ 0
+ <b>Auto Managed:</b>
+ True
- 2
- 3
+ 4
+ 5
+ 3
+ 4
GTK_FILL
-
+
True
- 15
- 5
-
-
- True
- 0
- <b>Speed:</b>
- True
-
-
- 2
- 3
+ 7
+ 8
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+ True
+
+
+ 7
+ 8
1
2
GTK_FILL
-
+
True
- 15
- 5
-
-
- True
- 0
- <b>ETA:</b>
- True
-
-
+ 0
+ <b>Seed Rank:</b>
+ True
- 2
- 3
+ 6
+ 7
2
3
GTK_FILL
+
+
+ True
+ 0
+ <b>Seeding Time:</b>
+ True
+
+
+ 6
+ 7
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+ True
+
+
+ 7
+ 8
+ GTK_FILL
+
+
+
+
+ True
+ 0
+ <b>Active Time:</b>
+ True
+
+
+ 6
+ 7
+ GTK_FILL
+
+
+
+
+ True
+ 0
+ True
+ True
+
+
+ 1
+ 2
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+ True
+ 0
+ PANGO_WRAP_CHAR
+ True
+
+
+ 1
+ 6
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+ True
+ 0
+ <b>Tracker Status:</b>
+ True
+
+
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ True
+ PANGO_WRAP_WORD_CHAR
+
+
+ 5
+ 6
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ 1
+ <b>Availability:</b>
+ True
+
+
+ 4
+ 5
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+ True
+ 0
+
+
+ 5
+ 6
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+ True
+ 0
+ <b>Peers:</b>
+ True
+
+
+ 4
+ 5
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+ True
+ 0
+
+
+ 5
+ 6
+ GTK_FILL
+
+
+
+
+ True
+ 0
+ <b>Seeders:</b>
+ True
+
+
+ 4
+ 5
+ GTK_FILL
+
+
True
@@ -854,273 +939,188 @@
-
+
True
- 0
- <b>Seeders:</b>
- True
+ 15
+ 5
+
+
+ True
+ 0
+ <b>ETA:</b>
+ True
+
+
- 4
- 5
- GTK_FILL
-
-
-
-
- True
- 0
-
-
- 5
- 6
- GTK_FILL
-
-
-
-
- True
- 0
- <b>Peers:</b>
- True
-
-
- 4
- 5
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- 0
-
-
- 5
- 6
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- 0
-
-
- 1
- 2
+ 2
+ 3
2
3
GTK_FILL
-
+
+ True
+ 15
+ 5
+
+
+ True
+ 0
+ <b>Speed:</b>
+ True
+
+
+
+
+ 2
+ 3
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+ True
+ 15
+ 5
+
+
+ True
+ 0
+ <b>Speed:</b>
+ True
+
+
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+ True
+ 5
+
+
+ True
+ 0
+ <b>Next Announce:</b>
+ True
+
+
+
+
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+ True
+ 5
+
+
+ True
+ 0
+ <b>Share Ratio:</b>
+ True
+
+
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+ True
+ 5
+
+
+ True
+ 0
+ <b>Uploaded:</b>
+ True
+
+
+
+
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+ True
+ 5
+
+
+ True
+ 0
+ <b>Downloaded:</b>
+ True
+
+
+
+
+ GTK_FILL
+
+
+
+
True
0
3
4
- 2
- 3
+ 1
+ 2
GTK_FILL
-
+
True
0
- 1
- <b>Availability:</b>
- True
-
-
- 4
- 5
- 2
- 3
- GTK_FILL
-
-
-
-
- True
- 0
- True
- PANGO_WRAP_WORD_CHAR
-
-
- 5
- 6
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- 0
- <b>Tracker Status:</b>
- True
-
-
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
- 0
- PANGO_WRAP_CHAR
- True
1
- 6
- 4
- 5
+ 2
+ 1
+ 2
GTK_FILL
-
+
True
0
3
4
- 3
- 4
GTK_FILL
-
+
True
0
- True
- True
1
2
- 3
- 4
- GTK_FILL
-
-
-
-
- True
- 0
- <b>Active Time:</b>
- True
-
-
- 6
- 7
- GTK_FILL
-
-
-
-
- True
-
-
- 7
- 8
- GTK_FILL
-
-
-
-
- True
- 0
- <b>Seeding Time:</b>
- True
-
-
- 6
- 7
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- 0
- <b>Seed Rank:</b>
- True
-
-
- 6
- 7
- 2
- 3
- GTK_FILL
-
-
-
-
- True
-
-
- 7
- 8
- 1
- 2
- GTK_FILL
-
-
-
-
- True
-
-
- 7
- 8
- 2
- 3
- GTK_FILL
-
-
-
-
- True
- 0
- <b>Auto Managed:</b>
- True
-
-
- 4
- 5
- 3
- 4
- GTK_FILL
-
-
-
-
- True
-
-
- 5
- 6
- 3
- 4
GTK_FILL
@@ -1207,7 +1207,7 @@
-
+
True
0
True
@@ -1215,42 +1215,28 @@
1
2
- 3
- 4
+ 4
+ 5
-
- True
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- 0
-
-
- 1
- 4
- 5
- 6
-
-
-
-
-
+
True
0
1
- <b>Status:</b>
+ <b># of files:</b>
True
- 5
- 6
+ 4
+ 5
GTK_FILL
-
+
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
0
@@ -1261,65 +1247,52 @@
1
4
- 2
- 3
+ 1
+ 2
-
+
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- 5
-
-
- True
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- 0
- <b>Path:</b>
- True
-
-
+ 0
+ <b>Hash:</b>
+ True
- 2
- 3
+ 1
+ 2
GTK_FILL
-
- True
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- 5
-
-
- True
- 0
- 0
- 1
- <b>Name:</b>
- True
-
-
-
-
- GTK_FILL
-
-
-
-
-
+
True
0
- True
- PANGO_WRAP_CHAR
True
1
4
+ 6
+ 7
+
+
+
+
+
+ True
+ 0
+ 1
+ <b>Tracker:</b>
+ True
+
+
+ 6
+ 7
+ GTK_FILL
@@ -1346,51 +1319,64 @@
-
- True
- 0
- 1
- <b>Tracker:</b>
- True
-
-
- 6
- 7
- GTK_FILL
-
-
-
-
-
+
True
0
+ True
+ PANGO_WRAP_CHAR
True
1
4
- 6
- 7
-
+
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- 0
- <b>Hash:</b>
- True
+ 5
+
+
+ True
+ 0
+ 0
+ 1
+ <b>Name:</b>
+ True
+
+
- 1
- 2
GTK_FILL
-
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ 5
+
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ 0
+ <b>Path:</b>
+ True
+
+
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
0
@@ -1401,28 +1387,42 @@
1
4
- 1
- 2
+ 2
+ 3
-
+
True
0
1
- <b># of files:</b>
+ <b>Status:</b>
True
- 4
- 5
+ 5
+ 6
GTK_FILL
-
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ 0
+
+
+ 1
+ 4
+ 5
+ 6
+
+
+
+
+
True
0
True
@@ -1430,8 +1430,8 @@
1
2
- 4
- 5
+ 3
+ 4
@@ -1614,7 +1614,7 @@
-
+
True
True
6
@@ -1624,100 +1624,8 @@
1
2
- 3
- 4
-
-
-
-
-
-
- True
- 0
- Max Upload Slots:
-
-
- 3
- 4
- GTK_FILL
-
-
-
-
-
- True
- KiB/s
-
-
- 2
- 3
- 1
- 2
-
-
-
-
-
-
- True
- KiB/s
-
-
- 2
- 3
-
-
-
-
-
-
- True
- 0
- Max Download Speed:
-
-
- GTK_FILL
-
-
-
-
-
- True
- 0
- Max Upload Speed:
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
-
- True
- 0
- Max Connections:
-
-
2
3
- GTK_FILL
-
-
-
-
-
- True
- True
- 6
- 1
- -1 -1 999999 1 10 10
- 1
-
-
- 1
- 2
@@ -1741,7 +1649,99 @@
-
+
+ True
+ True
+ 6
+ 1
+ -1 -1 999999 1 10 10
+ 1
+
+
+ 1
+ 2
+
+
+
+
+
+
+ True
+ 0
+ Max Connections:
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Max Upload Speed:
+
+
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Max Download Speed:
+
+
+ GTK_FILL
+
+
+
+
+
+ True
+ KiB/s
+
+
+ 2
+ 3
+
+
+
+
+
+
+ True
+ KiB/s
+
+
+ 2
+ 3
+ 1
+ 2
+
+
+
+
+
+
+ True
+ 0
+ Max Upload Slots:
+
+
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+
True
True
6
@@ -1751,8 +1751,8 @@
1
2
- 2
- 3
+ 3
+ 4
@@ -1777,6 +1777,118 @@
False
+
+
+ True
+ 0
+ GTK_SHADOW_NONE
+
+
+ True
+ 5
+ 12
+
+
+ True
+
+
+ True
+ True
+ Auto Managed
+ 0
+ True
+
+
+ False
+ False
+
+
+
+
+ True
+
+
+ True
+ 5
+
+
+ True
+ True
+ Stop seed at ratio:
+ 0
+ True
+
+
+ False
+ False
+
+
+
+
+ True
+ True
+ 1
+ 2 0 999 0.10000000000000001 10 10
+ 2
+
+
+ False
+ False
+ 1
+
+
+
+
+ False
+ False
+
+
+
+
+ True
+ 10
+
+
+ True
+ True
+ Remove at ratio
+ 0
+ True
+
+
+
+
+ False
+ False
+ 1
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+ True
+ <b>Queue</b>
+ True
+
+
+ label_item
+
+
+
+
+ False
+ False
+ 1
+
+
True
@@ -1788,6 +1900,7 @@
True
+ 5
12
@@ -1921,7 +2034,7 @@
False
False
- 1
+ 2
diff --git a/deluge/ui/gtkui/glade/torrent_menu.glade b/deluge/ui/gtkui/glade/torrent_menu.glade
index e232e10a3..60fa3fb99 100644
--- a/deluge/ui/gtkui/glade/torrent_menu.glade
+++ b/deluge/ui/gtkui/glade/torrent_menu.glade
@@ -306,6 +306,13 @@
+
+
+