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

Cannot get files of a torrent without unnecessary priorities and wanted fields #455

Open
cheeseandcereal opened this issue Jul 14, 2024 · 9 comments

Comments

@cheeseandcereal
Copy link
Contributor

Description

Currently, it is impossible to get files of a torrent (with the .get_files() interface) unless you fetch the priorities and wanted fields.

This is due to trying to directly reference these fields here:

priorities = self.fields["priorities"]
wanted = self.fields["wanted"]

It currently returns a key error if you try to use this:

    priorities = self.fields["priorities"]
                 ~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'priorities'

This doesn't really seem necessary and forces fetching these fields onto users for use-cases that may not need them.

I would propose updating this function or providing an alternative interface to get the files of a Torrent class

(as a side note, why are getting files a function interface while everything else on the class is a property? It seems a bit weird/inconsistent)

@cheeseandcereal
Copy link
Contributor Author

(As a note to others who find this issue before it's fixed)

A hacky workaround to this without actually fetching the additional fields is to just manually set the internal field state of the torrent yourself before calling .get_files() - i.e.:

torrent.fields["priorities"] = [0] * len(torrent.fields["files"])
torrent.fields["wanted"] = [True] * len(torrent.fields["files"])
# get_files() should now work
torrent.get_files()

@trim21
Copy link
Owner

trim21 commented Jul 14, 2024

ref #446

@trim21 trim21 closed this as completed Jul 14, 2024
@cheeseandcereal
Copy link
Contributor Author

cheeseandcereal commented Jul 14, 2024

A bit weird to close this issue because it's definitely not fixed by the mention of an unmerged PR. Unless you're saying you won't fix?

Should probably separate #446 out, or at least address separately since there's 2 different issues:

  1. Trying to call .get_files() if the files field wasn't fetched should return an error (not what I'm talking about with this issue at all)
  2. Trying to call .get_files() if the priorities or wanted fields aren't fetched should not fail

@trim21
Copy link
Owner

trim21 commented Jul 14, 2024

@cheeseandcereal
Copy link
Contributor Author

Shouldn't this issue remain open until at least it's merged then?

@trim21
Copy link
Owner

trim21 commented Jul 15, 2024

Yes, both your suggestions on splitting PR and keep issue open sounds reasonable to me. But I'm don't want to spend time on that PR just split it into 2 PR and resolve conflicts when I plan to merge it, so I'll just only re-open this issue.

@trim21 trim21 reopened this Jul 15, 2024
@cheeseandcereal
Copy link
Contributor Author

Yeah sounds good. It's just helpful to track this as an open issue. I appreciate it!

@trim21
Copy link
Owner

trim21 commented Jul 15, 2024

for tracking, I want to avoid unnecessary breaking change so I will merge PR and make new release when new transmission version is released.

@trim21
Copy link
Owner

trim21 commented Jul 15, 2024

you can use pip to install zip of PR if you need it now.

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