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

Int32 being rounded up to a number that doesn't fit in Int32 #5851

Closed
jacobschwartz1979 opened this issue Oct 21, 2016 · 6 comments
Closed
Labels
WebAPI WebAPI-related issues/changes

Comments

@jacobschwartz1979
Copy link

jacobschwartz1979 commented Oct 21, 2016

qBittorrent: 3.3.7
Qt: 5.7.0
libtorrent: 1.0.10.0
boost: 1.61.0
OS version: Windows 8.1 64 bit

I am using Sonarr (sonarr.tv) with QBittorrent. I have two items that currently have an ETA of infinity. When Sonarr is querying QBittorrent APIs it is getting a value for Int32 which is bigger than what Int32 can accommodate.

The number being returned by QBittorrent is 18446744073709552000 whereas it should be 18446744073709551615. It appears that the number is being rounded up when it shouldn't be.

Here is the exact message I get in the debug logs from Sonarr:

JSON integer 18446744073709552000 is too large or small for an Int32. Path '[43].eta', line 1, position 22385

Thanks for the support

@ghost
Copy link

ghost commented Oct 24, 2016

qBittorrent's WebUI API Documentation states eta is integer.
Why did Sonarr assume it's Int32?

@markus101
Copy link

qBittorrent's WebUI API Documentation states eta is integer.
Why did Sonarr assume it's Int32?

The dev that originally added Qbittorent support to Sonarr set it as an Int32. integer is pretty nondescript as a type especially when in this case it's looks like it's supposed to be unsigned, but priority is also listed as an integer, but needs to be signed since it can be -1.

We'll be updating Sonarr to properly consume the ulong ETA value, but the value returned from the API (18446744073709552000) exceeds the maximum value of an unsigned 64-bit number (18446744073709551615).

@ghost
Copy link

ghost commented Oct 25, 2016

@markus101
Ah now I see the point.
Thanks for the clarification.

@ghost
Copy link

ghost commented Nov 13, 2016

The source defined const qlonglong MAX_ETA = 8640000; (100 days)
but TorrentHandle::eta() returns greater than that. Looks bug to me.
I can't figure out why the WebUI API returns 18446744073709552000, but fixing this function
may solve the problem.

https://github.com/qbittorrent/qBittorrent/blob/master/src/base/bittorrent/torrenthandle.cpp#L859

qulonglong TorrentHandle::eta() const
{
    if (isPaused()) return MAX_ETA;

    const SpeedSampleAvg speed_average = m_speedMonitor.average();

    if (isSeed()) {
        if (speed_average.upload == 0) return MAX_ETA;

        qreal max_ratio = maxRatio();
        if (max_ratio < 0) return MAX_ETA;

        qlonglong realDL = totalDownload();
        if (realDL <= 0)
            realDL = wantedSize();

        return ((realDL * max_ratio) - totalUpload()) / speed_average.upload;
    }

    if (!speed_average.download) return MAX_ETA;

    return (wantedSize() - completedSize()) / speed_average.download;
}

Feel free to fix the function and test with Sonnar and make a PR.

@wQQhce2g93Ei
Copy link

Any update on when this might be merged/fixed?

@thalieht thalieht added the WebAPI WebAPI-related issues/changes label Jul 26, 2018
@xavier2k6
Copy link
Member

If you can reproduce this in latest 4.3.3, please create a "new issue"

@qbittorrent qbittorrent locked and limited conversation to collaborators Mar 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
WebAPI WebAPI-related issues/changes
Projects
None yet
Development

No branches or pull requests

5 participants