add time limits for seeding torrents
This commit is contained in:
parent
6b716c782d
commit
1c08462dd3
File diff suppressed because it is too large
Load Diff
27
src/core.py
27
src/core.py
|
@ -75,6 +75,7 @@ PREF_FUNCTIONS = {
|
|||
"max_active_torrents" : None, # no need for a function, applied constantly
|
||||
"max_upload_slots_global" : deluge_core.set_max_upload_slots_global,
|
||||
"auto_seed_ratio" : None, # no need for a function, applied constantly
|
||||
"auto_seed_time" : None, # no need for a function, applied constantly
|
||||
"max_download_speed_bps" : deluge_core.set_download_rate_limit,
|
||||
"max_upload_speed_bps" : deluge_core.set_upload_rate_limit,
|
||||
"enable_dht" : None, # not a normal pref in that is is applied only on start
|
||||
|
@ -171,6 +172,7 @@ class torrent_info:
|
|||
self.desired_ratio = 1.0
|
||||
self.trackers = ""
|
||||
self.trackers_changed = 0
|
||||
self.seed_time = 0
|
||||
|
||||
self.delete_me = False # set this to true, to delete it on next sync
|
||||
self.del_data = False # set this to true, to delete data on next sync
|
||||
|
@ -653,7 +655,6 @@ Space:") + " " + nice_free)
|
|||
if not self.get_pref('clear_max_ratio_torrents') \
|
||||
and self.get_pref('auto_seed_ratio') > 0 \
|
||||
and self.get_pref('auto_end_seeding'):
|
||||
|
||||
for unique_ID in self.unique_IDs:
|
||||
torrent_state = self.get_core_torrent_state(unique_ID)
|
||||
if (torrent_state["total_wanted"] - torrent_state["total_wanted_done"] == 0) and not torrent_state['is_paused']:
|
||||
|
@ -662,7 +663,19 @@ Space:") + " " + nice_free)
|
|||
self.queue_bottom(unique_ID, enforce_queue=False) # don't recurse!
|
||||
self.set_user_pause(unique_ID, True, enforce_queue=False)
|
||||
|
||||
if self.get_pref('clear_max_ratio_torrents'):
|
||||
if not self.get_pref('clear_max_rtime_torrents') \
|
||||
and self.get_pref('auto_seed_time') > 0 \
|
||||
and self.get_pref('auto_time_end_seeding'):
|
||||
for unique_ID in self.unique_IDs:
|
||||
torrent_state = self.get_core_torrent_state(unique_ID)
|
||||
if (torrent_state["total_wanted"] - torrent_state["total_wanted_done"] == 0) and not torrent_state['is_paused']:
|
||||
seed_time = self.unique_IDs[unique_ID].seed_time
|
||||
now = time.time()
|
||||
if (now - seed_time) >= (self.get_pref('auto_seed_time') * 3600):
|
||||
self.queue_bottom(unique_ID, enforce_queue=False) # don't recurse!
|
||||
self.set_user_pause(unique_ID, True, enforce_queue=False)
|
||||
|
||||
if self.get_pref('clear_max_ratio_torrents') and self.get_pref('auto_end_seeding'):
|
||||
for unique_ID in self.unique_IDs.keys():
|
||||
torrent_state = self.get_core_torrent_state(unique_ID)
|
||||
if (torrent_state["total_wanted"] - torrent_state["total_wanted_done"] == 0):
|
||||
|
@ -670,6 +683,15 @@ Space:") + " " + nice_free)
|
|||
if ratio >= self.get_pref('auto_seed_ratio'):
|
||||
self.removed_unique_ids[unique_ID] = 1
|
||||
self.remove_torrent(unique_ID, False, True)
|
||||
if self.get_pref('clear_max_time_torrents') and self.get_pref('auto_time_end_seeding'):
|
||||
for unique_ID in self.unique_IDs.keys():
|
||||
torrent_state = self.get_core_torrent_state(unique_ID)
|
||||
if (torrent_state["total_wanted"] - torrent_state["total_wanted_done"] == 0):
|
||||
seed_time = self.unique_IDs[unique_ID].seed_time
|
||||
now = time.time()
|
||||
if (now - seed_time) >= (self.get_pref('auto_seed_time') * 3600):
|
||||
self.removed_unique_ids[unique_ID] = 1
|
||||
self.remove_torrent(unique_ID, False, True)
|
||||
# Event handling
|
||||
|
||||
def connect_event(self, event_type, callback):
|
||||
|
@ -721,6 +743,7 @@ Space:") + " " + nice_free)
|
|||
# save fast resume once torrent finishes so as to not recheck
|
||||
# seed if client crashes
|
||||
self.save_fastresume_data(event['unique_ID'])
|
||||
self.unique_IDs[event['unique_ID']].seed_time = time.time()
|
||||
|
||||
elif event['event_type'] is self.constants['EVENT_FILE_ERROR']:
|
||||
import gtk
|
||||
|
|
|
@ -150,10 +150,14 @@ class PreferencesDlg:
|
|||
self.glade.get_widget("chk_queue_above_completed").set_sensitive(self.preferences.get("queue_seeds_to_bottom"))
|
||||
self.glade.get_widget("chk_queue_above_completed").set_active(self.preferences.get("queue_above_completed"))
|
||||
self.glade.get_widget("chk_autoseed").set_active(self.preferences.get("auto_end_seeding"))
|
||||
self.glade.get_widget("chk_autotime").set_active(self.preferences.get("auto_time_end_seeding"))
|
||||
self.glade.get_widget("chk_clear_max_ratio_torrents").set_sensitive(self.preferences.get("auto_end_seeding"))
|
||||
self.glade.get_widget("chk_clear_max_ratio_torrents").set_active(self.preferences.get("clear_max_ratio_torrents"))
|
||||
self.glade.get_widget("chk_clear_max_time_torrents").set_sensitive(self.preferences.get("auto_time_end_seeding"))
|
||||
self.glade.get_widget("chk_clear_max_time_torrents").set_active(self.preferences.get("clear_max_time_torrents"))
|
||||
self.glade.get_widget("chk_paused").set_active(self.preferences.get("start_paused"))
|
||||
self.glade.get_widget("ratio_spinner").set_value(self.preferences.get("auto_seed_ratio"))
|
||||
self.glade.get_widget("time_spinner").set_value(self.preferences.get("auto_seed_time"))
|
||||
self.glade.get_widget("chk_dht").set_active(self.preferences.get("enable_dht"))
|
||||
self.glade.get_widget("chk_use_advanced_bar").set_active(self.preferences.get("use_advanced_bar"))
|
||||
|
||||
|
@ -255,7 +259,8 @@ class PreferencesDlg:
|
|||
self.preferences.set("enable_multi_only", self.glade.get_widget("chk_enable_multi_only").get_active())
|
||||
self.preferences.set("prioritize_first_last_pieces", self.glade.get_widget("chk_prioritize_first_last_pieces").get_active())
|
||||
self.preferences.set("auto_end_seeding", self.glade.get_widget("chk_autoseed").get_active())
|
||||
self.preferences.set("auto_seed_ratio", self.glade.get_widget("ratio_spinner").get_value())
|
||||
self.preferences.set("auto_time_end_seeding", self.glade.get_widget("chk_autotime").get_active())
|
||||
self.preferences.set("auto_seed_time", self.glade.get_widget("time_spinner").get_value())
|
||||
self.preferences.set("use_compact_storage", self.glade.get_widget("radio_compact_allocation").get_active())
|
||||
self.preferences.set("listen_on", [self.glade.get_widget("spin_port_min").get_value(), self.glade.get_widget("spin_port_max").get_value()])
|
||||
self.preferences.set("max_upload_speed", self.glade.get_widget("spin_max_upload").get_value())
|
||||
|
@ -274,6 +279,7 @@ class PreferencesDlg:
|
|||
self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active())
|
||||
self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active())
|
||||
self.preferences.set("clear_max_ratio_torrents", self.glade.get_widget("chk_clear_max_ratio_torrents").get_active())
|
||||
self.preferences.set("clear_max_time_torrents", self.glade.get_widget("chk_clear_max_time_torrents").get_active())
|
||||
self.preferences.set("queue_above_completed", self.glade.get_widget("chk_queue_above_completed").get_active())
|
||||
self.preferences.set("start_paused", self.glade.get_widget("chk_paused").get_active())
|
||||
self.preferences.set("use_advanced_bar", self.glade.get_widget("chk_use_advanced_bar").get_active())
|
||||
|
@ -341,6 +347,9 @@ class PreferencesDlg:
|
|||
elif widget == self.glade.get_widget('chk_autoseed'):
|
||||
self.glade.get_widget('ratio_spinner').set_sensitive(value)
|
||||
self.glade.get_widget('chk_clear_max_ratio_torrents').set_sensitive(value)
|
||||
elif widget == self.glade.get_widget('chk_autotime'):
|
||||
self.glade.get_widget('time_spinner').set_sensitive(value)
|
||||
self.glade.get_widget('chk_clear_max_time_torrents').set_sensitive(value)
|
||||
elif widget == self.glade.get_widget('chk_seedbottom'):
|
||||
self.glade.get_widget('chk_queue_above_completed').set_sensitive(value)
|
||||
elif widget == self.glade.get_widget('chk_enable_files_dialog'):
|
||||
|
|
|
@ -48,12 +48,15 @@ if common.windows_check():
|
|||
"open_folder_location": "",
|
||||
"send_info" : True,
|
||||
"auto_end_seeding" : False,
|
||||
"auto_time_end_seeding" : False,
|
||||
"auto_seed_ratio" : 0,
|
||||
"auto_seed_time" : 0,
|
||||
"close_to_tray" : False,
|
||||
"enable_files_dialog" : False,
|
||||
"enable_multi_only" : True,
|
||||
"queue_above_completed" : False,
|
||||
"clear_max_ratio_torrents" : False,
|
||||
"clear_max_time_torrents" : False,
|
||||
"default_autoload_path" : os.path.expanduser("~"),
|
||||
"default_torrent_path" : os.path.join(os.path.expanduser("~"), 'deluge', 'torrentfiles'),
|
||||
"default_download_path" : os.path.expanduser("~"),
|
||||
|
@ -162,13 +165,16 @@ else:
|
|||
"open_folder_location": "",
|
||||
"send_info" : True,
|
||||
"auto_end_seeding" : False,
|
||||
"auto_time_end_seeding" : False,
|
||||
"new_releases" : True,
|
||||
"auto_seed_ratio" : 0,
|
||||
"auto_seed_time" : 0,
|
||||
"close_to_tray" : False,
|
||||
"enable_files_dialog" : False,
|
||||
"enable_multi_only" : True,
|
||||
"queue_above_completed" : False,
|
||||
"clear_max_ratio_torrents" : False,
|
||||
"clear_max_time_torrents" : False,
|
||||
"default_autoload_path" : os.path.expanduser("~"),
|
||||
"default_torrent_path" : os.path.join(xdg.BaseDirectory.save_config_path('deluge'), 'torrentfiles'),
|
||||
"default_download_path" : os.path.expanduser("~"),
|
||||
|
|
Loading…
Reference in New Issue