Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed transmission ratio calculation to total size instead of downloaded size #791

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

RA341
Copy link
Contributor

@RA341 RA341 commented Aug 20, 2024

Transmission ratio calculation was based on torrent.uploadedEver/torrent.downloadedEver, which caused some torrents not initiated in flood to have a ratio of -1.

Description

The calculation is now based on torrent.uploadedEver / torrent.totalSize

Related Issue

#720

Screenshots

Before change:

Note the ratio is -1

image

After change

Note the ratio is now correctly displayed: 0.01

image

  • Breaking change (changes that break backward compatibility of public API or CLI - semver MAJOR)
  • New feature (non-breaking change which adds functionality - semver MINOR)
  • Bug fix (non-breaking change which fixes an issue - semver PATCH)

@@ -383,7 +383,7 @@ class TransmissionClientGatewayService extends ClientGatewayService {
...(await Promise.all(
torrents.map(async (torrent) => {
const percentComplete = (torrent.haveValid / torrent.totalSize) * 100;
const ratio = torrent.downloadedEver === 0 ? -1 : torrent.uploadedEver / torrent.downloadedEver;
const ratio = torrent.totalSize === 0 ? -1 : torrent.uploadedEver / torrent.totalSize;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how could torrent.totalSize === 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's should not happen, but if it does might as well handle it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this will happen. also it's wrong. we should use totalSize based ratio only when torrent is not downloaded at all, which means torrent.downloadedEver === 0, not torrent.totalSize === 0

Copy link
Contributor Author

@RA341 RA341 Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see so something like this ?

const ratio = torrent.downloadedEver === 0 ? torrent.uploadedEver / torrent.totalSize : torrent.uploadedEver / torrent.downloadedEver;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@trim21 trim21 merged commit 69feefe into jesec:master Aug 21, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants