Add per-torrent move on completed settings
This commit is contained in:
parent
886939d64d
commit
af1f2205bb
|
@ -2,6 +2,7 @@ Deluge 1.1.0 - "" (In Development)
|
|||
Core:
|
||||
* Implement #79 ability to change outgoing port range
|
||||
* Implement #296 ability to change peer TOS byte
|
||||
* Add per-torrent move on completed settings
|
||||
|
||||
GtkUI:
|
||||
* Add peer progress to the peers tab
|
||||
|
|
|
@ -626,6 +626,14 @@ class Core(
|
|||
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_set_torrent_move_on_completed(self, torrent_id, value):
|
||||
"""Sets the torrent to be moved when completed"""
|
||||
return self.torrents[torrent_id].set_move_on_completed(value)
|
||||
|
||||
def export_set_torrent_move_on_completed_path(self, torrent_id, value):
|
||||
"""Sets the path for the torrent to be moved when completed"""
|
||||
return self.torrents[torrent_id].set_move_on_completed_path(value)
|
||||
|
||||
def export_block_ip_range(self, range):
|
||||
"""Block an ip range"""
|
||||
|
|
|
@ -88,7 +88,10 @@ class Torrent:
|
|||
self.stop_at_ratio = False
|
||||
self.stop_ratio = 2.00
|
||||
self.remove_at_ratio = False
|
||||
|
||||
|
||||
self.move_on_completed = False
|
||||
self.move_on_completed_path = deluge.common.get_default_download_dir()
|
||||
|
||||
# Load values from state if we have it
|
||||
if state is not None:
|
||||
# This is for saving the total uploaded between sessions
|
||||
|
@ -240,6 +243,12 @@ class Torrent:
|
|||
# Force a reannounce if there is at least 1 tracker
|
||||
self.force_reannounce()
|
||||
|
||||
def set_move_on_completed(self, value):
|
||||
self.move_on_completed = value
|
||||
|
||||
def set_move_on_completed_path(self, value):
|
||||
self.move_on_completed_path = value
|
||||
|
||||
def update_state(self):
|
||||
"""Updates the state based on what libtorrent's state for the torrent is"""
|
||||
# Set the initial state based on the lt state
|
||||
|
@ -459,7 +468,9 @@ class Torrent:
|
|||
"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
|
||||
"remove_at_ratio": self.remove_at_ratio,
|
||||
"move_on_completed": self.move_on_completed,
|
||||
"move_on_completed_path": self.move_on_completed_path
|
||||
}
|
||||
|
||||
fns = {
|
||||
|
|
|
@ -621,9 +621,15 @@ class TorrentManager(component.Component):
|
|||
torrent = self.torrents[torrent_id]
|
||||
log.debug("%s is finished..", torrent_id)
|
||||
# Move completed download to completed folder if needed
|
||||
if self.config["move_completed"] and not torrent.is_finished:
|
||||
if torrent.save_path != self.config["move_completed_path"]:
|
||||
torrent.move_storage(self.config["move_completed_path"])
|
||||
if not torrent.is_finished:
|
||||
move_path = None
|
||||
if torrent.move_on_completed:
|
||||
move_path = torrent.move_on_completed_path
|
||||
elif self.config["move_completed"]:
|
||||
move_path = self.config["move_completed_path"]
|
||||
if move_path:
|
||||
if torrent.save_path != move_path:
|
||||
torrent.move_storage(move_path)
|
||||
|
||||
torrent.is_finished = True
|
||||
torrent.update_state()
|
||||
|
|
|
@ -168,7 +168,8 @@ class BaseClient(object):
|
|||
"deregister_client", "register_client", "add_torrent_file",
|
||||
"set_torrent_prioritize_first_last", "set_torrent_auto_managed",
|
||||
"set_torrent_stop_ratio", "set_torrent_stop_at_ratio",
|
||||
"set_torrent_remove_at_ratio"]
|
||||
"set_torrent_remove_at_ratio", "set_torrent_move_on_completed",
|
||||
"set_torrent_move_on_completed_path"]
|
||||
|
||||
def __init__(self):
|
||||
self.core = _core
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -56,14 +56,29 @@ class OptionsTab(Tab):
|
|||
self.chk_stop_at_ratio = glade.get_widget("chk_stop_at_ratio")
|
||||
self.chk_remove_at_ratio = glade.get_widget("chk_remove_at_ratio")
|
||||
self.spin_stop_ratio = glade.get_widget("spin_stop_ratio")
|
||||
self.chk_move_completed = glade.get_widget("chk_move_completed")
|
||||
self.filechooser_move_completed = glade.get_widget("filechooser_move_completed")
|
||||
self.entry_move_completed = glade.get_widget("entry_move_completed")
|
||||
|
||||
self.prev_torrent_id = None
|
||||
self.prev_status = None
|
||||
|
||||
glade.signal_autoconnect({
|
||||
"on_button_apply_clicked": self._on_button_apply_clicked,
|
||||
"on_button_edit_trackers_clicked": self._on_button_edit_trackers_clicked
|
||||
"on_button_edit_trackers_clicked": self._on_button_edit_trackers_clicked,
|
||||
"on_chk_move_completed_toggled": self._on_chk_move_completed_toggled
|
||||
})
|
||||
|
||||
def start(self):
|
||||
if client.is_localhost():
|
||||
self.filechooser_move_completed.show()
|
||||
self.entry_move_completed.hide()
|
||||
else:
|
||||
self.filechooser_move_completed.hide()
|
||||
self.entry_move_completed.show()
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def on_button_press_event(self, widget, event):
|
||||
from deluge.ui.gtkui.notification import Notification
|
||||
|
@ -95,7 +110,9 @@ class OptionsTab(Tab):
|
|||
"is_auto_managed",
|
||||
"stop_at_ratio",
|
||||
"stop_ratio",
|
||||
"remove_at_ratio"])
|
||||
"remove_at_ratio",
|
||||
"move_on_completed",
|
||||
"move_on_completed_path"])
|
||||
self.prev_torrent_id = torrent_id
|
||||
|
||||
def clear(self):
|
||||
|
@ -129,6 +146,13 @@ class OptionsTab(Tab):
|
|||
self.spin_stop_ratio.set_value(status["stop_ratio"])
|
||||
if status["remove_at_ratio"] != self.prev_status["remove_at_ratio"]:
|
||||
self.chk_remove_at_ratio.set_active(status["remove_at_ratio"])
|
||||
if status["move_on_completed"] != self.prev_status["move_on_completed"]:
|
||||
self.chk_move_completed.set_active(status["move_on_completed"])
|
||||
if status["move_on_completed_path"] != self.prev_status["move_on_completed_path"]:
|
||||
if client.is_localhost():
|
||||
self.filechooser_move_completed.set_current_folder(status["move_on_completed_path"])
|
||||
else:
|
||||
self.entry_move_completed.set_text(status["move_on_completed_path"])
|
||||
|
||||
self.prev_status = status
|
||||
|
||||
|
@ -151,6 +175,14 @@ class OptionsTab(Tab):
|
|||
client.set_torrent_stop_ratio(self.prev_torrent_id, self.spin_stop_ratio.get_value())
|
||||
if self.chk_remove_at_ratio.get_active() != self.prev_status["remove_at_ratio"]:
|
||||
client.set_torrent_remove_at_ratio(self.prev_torrent_id, self.chk_remove_at_ratio.get_active())
|
||||
if self.chk_move_completed.get_active() != self.prev_status["move_on_completed"]:
|
||||
client.set_torrent_move_on_completed(self.prev_torrent_id, self.chk_move_completed.get_active())
|
||||
if self.chk_move_completed.get_active():
|
||||
if client.is_localhost():
|
||||
path = self.filechooser_move_completed.get_current_folder()
|
||||
else:
|
||||
path = self.entry_move_completed.get_text()
|
||||
client.set_torrent_move_on_completed_path(self.prev_torrent_id, path)
|
||||
|
||||
|
||||
def _on_button_edit_trackers_clicked(self, button):
|
||||
|
@ -159,3 +191,12 @@ class OptionsTab(Tab):
|
|||
self.prev_torrent_id,
|
||||
component.get("MainWindow").window)
|
||||
dialog.run()
|
||||
|
||||
def _on_chk_move_completed_toggled(self, widget):
|
||||
value = self.chk_move_completed.get_active()
|
||||
if client.is_localhost():
|
||||
widget = self.filechooser_move_completed
|
||||
else:
|
||||
widget = self.entry_move_completed
|
||||
|
||||
widget.set_sensitive(value)
|
||||
|
|
|
@ -284,9 +284,22 @@ class TorrentDetails(component.Component):
|
|||
self.show_tab(tab_name)
|
||||
elif not visible and self.tabs[tab_name].is_visible:
|
||||
self.hide_tab(tab_name)
|
||||
|
||||
|
||||
def start(self):
|
||||
for tab in self.tabs.values():
|
||||
try:
|
||||
tab.start()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def stop(self):
|
||||
self.clear()
|
||||
for tab in self.tabs.values():
|
||||
try:
|
||||
tab.stop()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
def shutdown(self):
|
||||
# Save the state of the tabs
|
||||
|
|
Loading…
Reference in New Issue