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

Should type of TorrentStatus.state be TorrentState instead of string? #37

Open
jerblack opened this issue Apr 22, 2021 · 1 comment
Open

Comments

@jerblack
Copy link

jerblack commented Apr 22, 2021

This may be a dumb question, but I saw that you went to the trouble of defining a TorrentState type and constants for each of the possible torrent states, so I tried to do an == comparison but couldn't because TorrentStatus.State is a string and the state constants are type TorrentState. Shouldn't TorrentStatus.State be type TorrentState?

// this should work but doesn't
tors, _ := d.client.TorrentsStatus(delugeclient.StateUnspecified, nil)
if tors[0].State == delugeclient.StateSeeding {
  // seeding!
}

This works if I cast the TorrentState constant to a string ( string(delugeclient.StateSeeding) ) or cast the torrent state from string to TorrentState ( delugeclient.TorrentState(tors[0].State) ) but it seems like they should already be the same type.

@gdm85
Copy link
Owner

gdm85 commented May 2, 2021

No, it is not a dumb question - I think it does not have the right type because of the "conversion magic" that happens when decoding the python RPC data.

I am not sure how to easily fix this at the moment 🤔

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

No branches or pull requests

2 participants