Skip to content

Commit

Permalink
add post_removal_sleep_sec config item
Browse files Browse the repository at this point in the history
- if set to value > 0 and also hdd_space is set to > 0, then we
  sleep/pause that amount of seconds after each & every torrent removal.

  this is to try and mitigate situation where one ARP invocation causes
  removal of multiple torrents, but on some seedboxes it takes some
  seconds for the HDD space to be reported as freed up. this means the
  same invocation would end up removing more torrents than _really_
  allowed by the set hdd_space config/rule.
  • Loading branch information
laur89 committed Nov 19, 2024
1 parent 081849c commit dfc7b51
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ steps:
#- git config --global user.name "Zest Releaser"
#- git remote set-url origin ${DRONE_GIT_SSH_URL}
#- git config --global push.autoSetupRemote true
- pip install zest.releaser
- pip --no-cache-dir install zest.releaser
# TODO: consider towncrier for changelog updates
#- pip install zestreleaser.towncrier
#- pip install --no-cache-dir zestreleaser.towncrier
- fullrelease --no-input
#- git push origin --tags
when:
Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
## 0.6.5 (unreleased)

- Nothing changed yet.

- add `post_removal_sleep_sec` config item

- if set to value > 0 and also hdd_space is set to > 0, then we
sleep/pause that amount of seconds after each & every torrent removal.

this is to try and mitigate situation where one ARP invocation causes
removal of multiple torrents, but on some seedboxes it takes some
seconds for the HDD space to be reported as freed up. this means the
same invocation would end up removing more torrents than _really_
allowed by the set hdd_space config/rule.
defaults to `-1`, i.e. feature is disabled

## 0.6.4 (2024-10-16)

Expand Down
9 changes: 8 additions & 1 deletion autoremoveplus/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def wrapper(*args, **kwargs):
'reannounce_max_wait_sec': 20,
'skip_removal_on_reannounce_failure': True,
'remove': True,
'post_removal_sleep_sec': -1.0,
'enabled': False,
'tracker_rules': {},
'label_rules': {},
Expand Down Expand Up @@ -559,7 +560,7 @@ async def periodic_scan(self, *args, **kwargs):

# check if free disk space below minimum
if self.check_min_space():
break # break the loop, we have enough space
break # we have enough space, do not remove any more

log.debug(
"periodic_scan(): starting remove-torrent rule checking for [%s], %s"
Expand Down Expand Up @@ -639,6 +640,12 @@ async def periodic_scan(self, *args, **kwargs):
# note we deferToThread because of time.sleep() downstream
if await threads.deferToThread(lambda: self.remove_torrent(i, t, remove_data)):
changed = True
# sleep a bit post-removal to give time for hdd space to be freed up;
# on some seedboxes I've seen it takes a long time for space to be
# reported as freed up, which can cause too many torrents to be removed
# in the same invocation:
if self.config['hdd_space'] > 0.0 and self.config['post_removal_sleep_sec'] > 0.0:
await threads.deferToThread(lambda: time.sleep(self.config['post_removal_sleep_sec'])):

# If a torrent exemption state has been removed save changes
if changed:
Expand Down

0 comments on commit dfc7b51

Please sign in to comment.