-
Notifications
You must be signed in to change notification settings - Fork 276
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
Fixed Transmission (and prob others) authentication. #9598
Conversation
p0psicles
commented
Jun 1, 2021
•
edited
Loading
edited
- self.get_auth() was called just after self.url = None was set.
- PR is based on the DEVELOP branch
- Don't send big changes all at once. Split up big PRs into multiple smaller PRs that are easier to manage and review
- Read the contribution guide
* self.get_auth() was called just after self.url = None was set.
@p0psicles |
Yeah, but the issue was the order.. get_auth() needs to url for some clients. And get_auth was called in the GenericClient init. And at that point URL wasn't initialized yet |
If you call self.get_auth() in the _init of the generic.py it will call the get_auth() of the client module. I tested it with Download Station and Transmission and both worked fine. |
It didn't work well with qbittorrent.
There is no implicit call to the client module init. And thats a good thing. Else you would get into a loop. As the client module init will again call the super() which will call the get_auth().. Etc. Only thing I could do is move the get_auth back to generic. And put the super call behind the url = ... |
I think it also was an issue with rtorrent. As I use that myself. And the test_authentication was failing before this pr was merged. |
The init of a class is always called before any of the functions within the class is called. I looked at rtorrent and I saw the the self.url is not used nor filled at all in self._get_auth() so that can be problematic and create a loop. So to prevent a loop for those clients you can add the self._get_auth() call to the send_torrent function of the generic.py to be sure the session is authorized. Because GenericClient() is not used to create an object with but called directly, non of the self variables nor the session header nor cookies are kept alive so before every call to a client the self._get_auth() must be called to create those fresh. |
I really don't know why you think we don't create objects. I've explained in this comment. #9482 (comment) |
Because I tested it. Otherwise where is the object created?
And a call to add a torrent should look like Then at that moment the GenericTorrentClientObject is created from the class template and the init code is executed only once. But is you call the GenericClient() directly it only function as a set of methodes without keeping the self data alive. If you don't believe me, just put a debug statement in the init of GenericClient and in the init of rtorrent and you will notice that when adding a torrent both init are execute every time and normal object behavior would be that the init is only executes at creation time of that object( so just once). |
@BenjV |
@medariox If you want to use it as an object somewhere in the application it must be create once and only once and not every time new because then all the object data is gone and you only have an object in name not in functionality. For medusa it would be best to create the client object the moment the user chooses which the torrent client to use. |