anthonyraymond / joal

An open source command line RatioMaster with an optional WebUI.
Apache License 2.0
572 stars 63 forks source link

Added ratio limiter #193

Closed ashaychangwani closed 8 months ago

ashaychangwani commented 1 year ago

I've added code to limit the upload/download ratio to exactly 1.0

It automatically archives the torrent and announces it to the tracker once it is being deleted.

In the next few commits, I'll write code to add a configuration parameter to set the ratio to a customizable level, while also giving the option to disable the ratio limiter.

If there's any issue with the current codebase changes, do let me know, and I'll consider them for the future commits as well!

JourneyOver commented 1 year ago

Would love to see this get implented in @anthonyraymond would mean I could finally get rid of my script that auto deletes .torrent files after a certain amount of hours xD

also @ashaychangwani when you plan on getting the code added for the configuration parameter to set the ratio?

ashaychangwani commented 1 year ago

also @ashaychangwani when you plan on getting the code added for the configuration parameter to set the ratio?

I'm working on it, but having some issues since the file structure is different between Joal and Joal-Desktop. I'm not good enough at front-end to reconcile them, but once I can figure that out, adding the parameters should be easy.

Another major issue I'm working on is that even though Joal seems like it's doing everything correctly (Announcing right before the torrent is deleted) after it's done seeding, many times that announcement is not captured by the indexer I use. I'm working on a new implementation that just sets the speed to 0 once it's done seeding, then when Joal completes it's automatic announce at 30 minutes, I'll delete the torrent from Joal.

rursache commented 1 year ago

@ashaychangwani please make the default to be "no ratio limit" to not break/change the behavior of existing setups! thanks

ashaychangwani commented 1 year ago

also @ashaychangwani when you plan on getting the code added for the configuration parameter to set the ratio?

Done.

@ashaychangwani please make the default to be "no ratio limit" to not break/change the behavior of existing setups! thanks

Done.

@anthonyraymond not sure how we proceed from here, but it seems like the expected functionality is achieved.

anthonyraymond commented 1 year ago

Hello, thanks for your PR 😄

I'm sorry i haven't looked at the code yet, i don't have much spare time these days. have you looked at my comment at your issue: https://github.com/anthonyraymond/joal/issues/191#issuecomment-1430986155 ? Before i take a look at the code, can you tell me if the "check list" is completed?

ashaychangwani commented 1 year ago

Sure!

  • [X] Ensure the project still start even if the joal.conf does not contains the new entries
  • [-] Make the ratio-limit an object containing (bool enabled, int maxRatio), don't inline those two properties in the JoalConfig please.

I have taken a different approach, where the ratio is a float and -1 is set to infinity, and users can customize their ratio. By default (even when there is no entry in the config), it's set to -1.

  • [X] Make it opt-in (off by default)
  • [X] As is, the feature only work if the upload happen in a single session (ratio is not considered reach if a upload 50%, stop, upload the remaining 50%). Please add a side note to the UI config page.

Screenshot of settings page:

image
anthonyraymond commented 1 year ago

Hello there, i've not forgotten about you.

But i'm lacking time to review that. I try to give it a look ASAP

JourneyOver commented 8 months ago

Any word on this by chance still getting a review and such? still would love to get this implemented at some point.

anthonyraymond commented 8 months ago

Hello @ashaychangwani, Thanks for your PR, i've ended up coding the functionality in a different way (#221) because the current implementation had potential race conditions and some concurrent access that may have cause issues in rare but possible use cases.

However, i'll gladly accept a PR on the joal-ui project including what you've done to add the checkbox and API call.

anthonyraymond commented 8 months ago

Closed in favor of #221