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

Show downloading files in peers list. Attempt #2 #4867

Merged
merged 2 commits into from
Mar 14, 2016
Merged

Show downloading files in peers list. Attempt #2 #4867

merged 2 commits into from
Mar 14, 2016

Conversation

zeule
Copy link
Contributor

@zeule zeule commented Feb 27, 2016

This reverts reversion and fixes torrent_info::map_block() call, providing the correct piece size to it. Hopefully now it will not lead to crashes like in issue #4597

@@ -408,3 +408,8 @@ QString PeerInfo::flagsDescription() const
{
return m_flagsDescription;
}

int PeerInfo::downloadingPieceIndex() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning to our discussion about the right design...
Instead to create a logical for external code QStringList PeerInfo::downloadingFiles() method, you put in the interface int PeerInfo::downloadingPieceIndex() method which nobody wants and which in this case can be attributed to the implementation details (let me remind you again that our classes are not wrappers around the libtorrent classes). Because of this mistake you move part of the logic in the calling code:

torrent->info().filesForPiece(peer.downloadingPieceIndex())

, although it should contain only following:

peer.downloadingFiles()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree and will change the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, not everything looks good after some thinking. Here is the problem:

TorrentInfo::filesForPiece() is good function (and I need it for another similar feature, highlighting of the downloading files and listing them in the tooltip for the torrent progress bars, not submitted yet). Thus should we implement PeerInfo::downloadingFiles() we either need to pass a reference to TorrentInfo instance there (currently it has libtorrent::peer_info or to duplicate code ( 👎 ). At the same time the current solution seems to be normalized (in terms of relational DB normalization). I guess the libtorrent authors arrived to the current design not unintentionally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thus should we implement PeerInfo::downloadingFiles() we either need to pass a reference to TorrentInfo instance there (currently it has libtorrent::peer_info or to duplicate code ( 👎 ).

In this case we should store TorrentHandle pointer inside PerrInfo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TorrentInfo::filesForPiece() is good function (and I need it for another similar feature, highlighting of the downloading files and listing them in the tooltip for the torrent progress bars, not submitted yet).

PeerInfo::downloadingFiles() is not enough for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the main difference between the TorrentHandle and TorrentInfo classes from your point of view? Could you tell me, please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the main difference between the TorrentHandle and TorrentInfo classes from your point of view? Could you tell me, please?

What does that have to this issue? And what about my point of view? They do not depend on it.
TorrentInfo is some static torrent data (metadata and other such things are usually stored in the torrent file). TorrentHandle is a dynamic torrent data (i.e. its current downloading/seeding state etc.) and provides a management interface. TorrentHandle also includes static torrent information and provides some wrappers to it for convenience.

But why do you ask that? I just wish you hadn't used low-level features in the GUI code.
This is reminiscent of the following situation (I like to make Parallels with real life):
You come in the cafe and want to eat, say, a cheeseburger. But the waiter brings you all the ingredients separately and you have to cook himself a cheeseburger.
Kitchen should prepare, and the client has to get his cheeseburger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the answers!

This has to do with the second use case. The use case of the progress bar. There I show piece contents and file extension over pieces in the torrent progress bars. There are no peers in that case. There might be no downloading process either. I need just static information about the torrent layout. Needed functions come from the torrent_info class and I added an utility function to the TorrentInfo class.

From the answer you gave me I see now that this is in agreement with your view too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Let's postpone this question for now. As I said, it's hard for me to discuss something I have not seen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it is: #4936

@sledgehammer999
Copy link
Member

Leaving a small comment here without looking the above discussion. This goes hand in hand with #4767

@sledgehammer999
Copy link
Member

#4767 is now merged. Should I merge this too?

@zeule
Copy link
Contributor Author

zeule commented Mar 13, 2016

@sledgehammer999, I believe the problem that has been leading to a crash was fixed, so, yes, please merge this one.

@zeule
Copy link
Contributor Author

zeule commented Mar 13, 2016

Just checked with Qt5 build: the "Files" column can be hid and shown back.

@sledgehammer999
Copy link
Member

Yeah, all are automatic with new columns being added.
Thanks for the fix.

sledgehammer999 added a commit that referenced this pull request Mar 14, 2016
Show downloading files in peers list. Attempt #2
@sledgehammer999 sledgehammer999 merged commit 8c36f75 into qbittorrent:master Mar 14, 2016
@glassez
Copy link
Member

glassez commented Mar 14, 2016

@sledgehammer999 your behavior causes my concern. This PR had the unsolved problem. However, it refers not to the user-visible functionality but to code design. Have we stopped to pay attention to this?
Now I have to fix it myself...

@zeule
Copy link
Contributor Author

zeule commented Mar 14, 2016

@glassez, this PR had "revert revert" commit and a bugfix for that first commit. Why don't you share your concerns in the PR #4936?

@sledgehammer999
Copy link
Member

@glassez the concerns were in a previously accepted code, which was reverted due to another bug. Plus there is #4936 where all concerns should be solved there, including for this PR's functionality.
I suspect @evsh will do the necessary changes there.

@glassez
Copy link
Member

glassez commented Mar 14, 2016

Ok. Let @evsh do the necessary changes in #4936.

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

Successfully merging this pull request may close these issues.

3 participants