Pre check if share limits are reached

This commit is contained in:
Erik Müller 2025-11-24 17:12:56 +01:00 committed by bobokun
parent 47308469ed
commit 2dfe50a304

View file

@ -333,22 +333,10 @@ class ShareLimits:
logger.print_line(logger.insert_space(f"Tracker: {tracker['url']}", 8), self.config.loglevel)
if self.group_tag:
logger.print_line(logger.insert_space(f"Added Tag: {self.group_tag}", 8), self.config.loglevel)
self.update_share_limits_for_torrent(torrent, group_config, tor_reached_seed_limit, torrent_upload_limit)
self.process_share_limits_for_torrent(torrent, group_config, tor_reached_seed_limit, torrent_upload_limit)
self.stats_tagged += 1
self.torrents_updated.append(t_name)
# Take action when torrent meets share limits
if tor_reached_seed_limit:
if group_config["cleanup"]:
# Queue for cleanup (delete .torrent and possibly contents)
if t_hash not in self.tdel_dict:
self.tdel_dict[t_hash] = {}
self.tdel_dict[t_hash]["torrent"] = torrent
self.tdel_dict[t_hash]["content_path"] = util.path_replace(
torrent["content_path"], self.root_dir, self.remote_dir
)
self.tdel_dict[t_hash]["body"] = tor_reached_seed_limit
self.torrent_hash_checked.append(t_hash)
def update_share_limits_tag_for_torrent(self, torrent):
@ -367,9 +355,21 @@ class ShareLimits:
if self.group_tag:
torrent.add_tags(self.group_tag)
def update_share_limits_for_torrent(self, torrent, group_config, tor_reached_seed_limit, torrent_upload_limit):
def process_share_limits_for_torrent(self, torrent, group_config, tor_reached_seed_limit, torrent_upload_limit):
"""Updates share limits for a torrent"""
# Take action when torrent meets share limits
if tor_reached_seed_limit:
if group_config["cleanup"]:
# Queue for cleanup (delete .torrent and possibly contents)
t_hash = torrent.hash
if t_hash not in self.tdel_dict:
self.tdel_dict[t_hash] = {}
self.tdel_dict[t_hash]["torrent"] = torrent
self.tdel_dict[t_hash]["content_path"] = util.path_replace(
torrent["content_path"], self.root_dir, self.remote_dir
)
self.tdel_dict[t_hash]["body"] = tor_reached_seed_limit
else:
# New behavior: throttle upload speed instead of pausing/removing
throttle_kib = group_config.get("upload_speed_on_limit_reached", 0)
# Apply per-torrent upload throttle (KiB/s) or unlimited if -1/0