-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Pause session till all torrents are fully started #9007
Conversation
@sledgehammer999 if I remove the disk where the torrent was downloaded and start the qbittorrent what will happen with the percentage completed? Will keep 100% but will indicate error? |
@sledgehammer999, well, great job!
|
src/gui/categoryfiltermodel.cpp
Outdated
@@ -181,6 +181,12 @@ CategoryFilterModel::CategoryFilterModel(QObject *parent) | |||
connect(session, &Session::categoryRemoved, this, &CategoryFilterModel::categoryRemoved); | |||
connect(session, &Session::torrentCategoryChanged, this, &CategoryFilterModel::torrentCategoryChanged); | |||
connect(session, &Session::subcategoriesSupportChanged, this, &CategoryFilterModel::subcategoriesSupportChanged); | |||
connect(session, &Session::finishedStartingUp, this, | |||
[this, session]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move it on the previous line in all similar cases of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the lambda? Have it as a one liner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 2nd thought, you probably mean only the capture clause and parameter list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 2nd thought, you probably mean only the capture clause and parameter list.
Yes.
src/base/bittorrent/session.cpp
Outdated
@@ -3808,11 +3786,14 @@ void Session::startUpTorrents() | |||
QByteArray data; | |||
} TorrentResumeData; | |||
|
|||
m_nativeSession->pause(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if we can create session in paused state.
src/base/bittorrent/session.cpp
Outdated
@@ -4009,6 +3990,12 @@ void Session::handleAlert(libt::alert *a) | |||
case libt::add_torrent_alert::alert_type: | |||
handleAddTorrentAlert(static_cast<libt::add_torrent_alert*>(a)); | |||
break; | |||
case libt::torrent_added_alert::alert_type: | |||
if (m_startupInProgress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't break the current style. Just add handleTorrentAddedAlert()
method.
src/base/bittorrent/session.cpp
Outdated
if (m_startupInProgress) | ||
--m_startedCount; | ||
if (m_startedCount == 0 && m_startupInProgress) | ||
handleStartUpFinish(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleStartUpFinished
src/base/bittorrent/session.h
Outdated
@@ -538,6 +538,7 @@ namespace BitTorrent | |||
void subcategoriesSupportChanged(); | |||
void tagAdded(const QString &tag); | |||
void tagRemoved(const QString &tag); | |||
void finishedStartingUp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startupFinished
src/gui/categoryfiltermodel.cpp
Outdated
connect(session, &Session::finishedStartingUp, this, | ||
[this, session]() | ||
{ | ||
for (const auto &handle : session->torrents().values()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add qAsConst()
?
or use iterator to loop, this avoids redundant traverse over the container, although I like the use of values() :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I am still confused about those macros. Eventually I'll get the hang of them.
I agree with the idea, making it unavailable seems simpler.
Since this is an interactive program, displaying no GUI would be a bad choice. |
Session doesn't emit signals for resumed torrents in changed code, only one startupFinished signal, and I really like this idea. |
We still need queuing at least for "add torrent" action since the application can start with torrents specified in command line. Of course, we can implement it outside the Session. |
6ea2f57
to
bfe97ba
Compare
I addressed some of the comments in my 3rd commit I pushed 2 new commits. Now the initial loading of the torrents is done in a separate thread. However, for me, the mainwindow still takes quite a few seconds to draw its contents. The initial blank/white window is drawn quickly. The widgets are taking quite a few seconds. |
Haven't tried this PR yet, (for you) does it still take seconds to draw the GUI even when there are no torrents? |
bfe97ba
to
fff13be
Compare
@sledgehammer999 I would like to test this PR in Windows. If I do: ./configure
make && make install
qbittorrent on Linux and copying the files to Windows will work? |
fff13be
to
2ca6cd2
Compare
@sledgehammer999, unfortunately I can't say that I approve this PR in its current form. It's more like a rough workaround (in terms of its design). P.S. Have you ever thought of having an additional release manager? This could help to make releases on time. It is a very hateful situation, when hotfixes "rot" in the master for several months while the bugtracker is filled with duplicate issues! |
I have this problem too. Looks like add_torrent with flag_override_resume_data can help solve this problem. |
@sledgehammer999, you still want to do something about it? |
Just so that I understand - this potential fix, or for that matter maybe any other, has been around for a bit over a year and more than just a few version updates and we've still got this as a problem? |
The problems it was supposed to solve (at least most of them) are now solved in a different way. |
So moving or deleting data of a formerly completed torrrent will in no case any longer cause a redownload? |
This should be fixed now. |
The goal was achieved in a different way. |
There were many user reports that complained that qbt started downloading over their data when they had forgotten to plugin the drive the torrents were in. Or forgotten to mount the partition/share etc.
I was confused because I personally had implemented a measure against this. I was even more confused because I couldn't reproduce it. Until some days ago. After a lot of trial and error it turns out that during startup libtorrent produces a ton of alerts. A lot more than 1000 at a time. And these alerts ended up throwing out of the queue the
fastresume_rejected_alert
alerts, thus my counter measure was never activated. A longer discussion here: arvidn/libtorrent#3045Naturally as I had delved into this I discovered other inefficiencies. There's a timing issue where the torrent might start downloading and writing data to disk before we have the chance to pause it.
I opted to have the session paused untill all torrents were loaded and handled.
To my experience, the 3 alerts that interest us are received in this order:
add_torrent_alert
->fastresume_rejected_alert
->torrent_added_alert
About the "Temp solution" commit. This is temporary fix in order to publish the PR and have feedback from you. Relevant bug report: arvidn/libtorrent#3071
IMO, it's better to see each commit by itself.
Caveats: