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

Add total disk space to free-space RPC request #1682

Merged

Conversation

johman10
Copy link
Contributor

Hi! I'm the creator of Flood for Transmission and I was working on a little detail panel that shows the available space. In that panel I was hoping to show user configured paths and how much space is available with a progress bar kind of representation.

However as of today Transmission doesn't let me know how much space is available in total. For this purpose I made this PR. It basically also returns the amount of bytes that the disk has in total (along side the untouched free space).

To do this I had to dig through some layers all the way to the deepest native call and pass it back up, which I used a struct for. Please review carefully as this is my first ever work in any form of C so I may have done somethings a bit different than conventional. But if so, please do let me know and I can look at it, or feel free to update the PR yourself if you feel like it.

I tested this on Linux (via Windows subsystem) with a Postman request see below:
image

I don't know how else to test this so let me know if something is off.

@lgtm-com
Copy link

lgtm-com bot commented Apr 28, 2021

This pull request introduces 1 alert when merging d34ec4a into faafc9e - view on LGTM.com

new alerts:

  • 1 for Comparison result is always the same

libtransmission/utils.h Show resolved Hide resolved
libtransmission/platform-quota.c Outdated Show resolved Hide resolved
@johman10
Copy link
Contributor Author

So I have been trying a bunch of things but fail to get a passing windows build. Problem is the following:
C:\BuildAgent2\work\1f3bff43dd55cfe9\libtransmission\utils.h(87,22): error C2526: 'tr_getDirSpace': C linkage function cannot return C++ class 'tr_disk_space'

I have no idea what's going on here. @ckerr do you have any idea how to resolve this? Feel free to change the PR to what's needed or let me know how to resolve it.

As I mentioned before this is one of the first times looking at C so this is not clear to me at all.

@ckerr
Copy link
Member

ckerr commented Oct 8, 2021

Hmm I see I left this PR in limbo. Sorry about that @johman10. Is this feature something your'e still interested in, and would you be willing to update the PR to sync with all the recent changes in master? It doesn't look like the conflicts would be too extreme and will likely fix the C linkage cannot return C++ class 'disk space' error as a happy side-effect 🙂

@johman10
Copy link
Contributor Author

@ckerr I'm still interested in this and wouldn't mind updating this PR.

I can have a look at it soon-ish. Can't promise any timeframe right now but I will aim to find some time this week. :)

@ckerr
Copy link
Member

ckerr commented Oct 12, 2021

ftbfs on lgtm:

2021-10-12 17:38:38] [build-stderr] /opt/src/libtransmission/platform-quota.cc: In function ‘tr_disk_space getquota(const char*)’:
[2021-10-12 17:38:38] [build-stderr] /opt/src/libtransmission/platform-quota.cc:363:17: error: could not convert ‘-1’ from ‘int’ to ‘tr_disk_space’
[2021-10-12 17:38:38] [build-stderr]   363 |         return -1;
[2021-10-12 17:38:38] [build-stderr]       |                 ^
[2021-10-12 17:38:38] [build-stderr]       |                 |
[2021-10-12 17:38:38] [build-stderr]       |                 int

@johman10
Copy link
Contributor Author

@ckerr I updated the branch and it seems like the builds will pass now, as you predicted.

Please give it another review when you have time! :)

extras/rpc-spec.txt Outdated Show resolved Hide resolved
@ckerr ckerr merged commit 04f8b82 into transmission:master Oct 14, 2021
@ckerr ckerr added type:feat A new feature and removed enhancement labels Oct 17, 2021
ckerr added a commit that referenced this pull request Oct 18, 2021
fix: unused variable warning in free-space code
ckerr added a commit that referenced this pull request Oct 18, 2021
fix: unused variable warning in free-space code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants