Commit graph

262 commits

Author SHA1 Message Date
sledgehammer999
80d6a5a73e Allow disabling of OS cache. This will prevent RAM increases on Windows when seeding many files. Closes #1699. 2014-08-07 23:09:58 +03:00
sledgehammer999
d8d95d2195 Migrate everything to use the new Preferences class and not access directly the qbittorrent.ini file. 2014-08-05 02:34:21 +03:00
sledgehammer999
e2748ec3ac Remove deprecated feature of separate DHT port. 2014-07-16 00:17:21 +03:00
sledgehammer999
d6d20074be Merge pull request #1447 from BrunoReX/hibernation
Add option to hibernate computer in Auto-Shutdown menu
2014-07-06 23:11:29 +03:00
sledgehammer999
9a18b50751 Some fixes for commit 6dabf50781. 2014-07-06 21:39:27 +03:00
Bruno Barbieri
00e09435b2 Add option to hibernate computer in Auto-Shutdown menu 2014-07-06 06:13:36 -03:00
Ivan Sorokin
6dabf50781 Speedup and fix a bug in torrent moving.
This commit implements a map where qbittorrent store a state of
current torrent movings. This commit speed up
torrents moving a bit and also fix a bug when qbittorrent doesn't do
cleanup action when a single torrent is moved several times without
waiting for a previous move to complete.

How it worked before.

Libtorrent has a function torrent_handle::move_storage() that allows to move a
torrent to a specific directory. This function is asynchorous. It means that
this function quits instantaneously and when the actual operation
completes the alert 'storage_moved_alert' or
'storage_moved_failed_alert' will be sent. The storage_moved_alert contains a
torrent_handle and a new path to where the torrent is moved.

During handling of storage_moved_alert, qbittorrent needs not only new path,
but also an old path to perform some of cleanup actions (like removing an old
folder if it is empty). This was achieved by storing a value named
'previous save path' in TorrentPersistentData. A previous save path is
written when move_storage() is issued and is read when
storage_moved_alert is received.

Problems.

This mechanism has two negative aspects:

1. TorrentPersistentData is very slow. As torrent_handle::move_storage() is asynchoronous,
TorrentPersistentData is responsible for more that 99.8% of time
QTorrentHandle::move_storage(). This percent could be higher when there
are lots of torrents and lower when there are few of them.

2. TorrentPersistentData stores only one previous path. But many
move_storage()'s could be issued without waiting for previous to
complete. Subsequent move_storage()'s overwrites previous save path of a
previous move.

A fix.

The fix is simple. Before issueing move_storage() the oldPath is stored in
a special map called 'torrentMoveStates'. When a storage_moved_alert
is received the map is consulted and an alert is handled.

When user moves torrent when previous moving have not yet finished, the
new location is saved in a field 'queuedPath' the same map. When
torrent moving is completed (or failed) qbittorrent attemps to perform
move again to the queued location.

Future direction.

This fix removes one slow read and one slow write to
TorrentPersistentData on torrent moving, but there is still exists
TorrentPersistentData::saveSavePath in handleStorageMovedAlert(), so
overall time for UI hang should be reduced only threefold. A speeding up
TorrentPersistentData should be addressed in a separate commit.

I don't know if I should clean up torrentMoveStates when torrent is
deleted. In any case, torrent could be deleted when corresponding alert
is in alert queue. So if we decide to clean up torrentMoveStates, then
we should not treat receiving alert from unknown torrent as a error.
2014-06-23 11:21:24 +04:00
sledgehammer999
d58d87a691 Use completed time from libtorrent directly. Closes #1726. 2014-06-07 14:44:08 +03:00
Ivan Sorokin
510818d631 Replaced dynamic_cast with switch on alert type.
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-04 11:08:31 +04:00
Ivan Sorokin
1244a46cbb Extract alert handling to separate functions. 2014-06-04 11:08:31 +04:00
sledgehammer999
a6fa27467f Fix previous commits. 2014-06-03 21:19:25 +03:00
Ivan Sorokin
c2a23f2265 use stats_alert in TorrentSpeedMonitor
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:35:27 +04:00
Ivan Sorokin
6f38616193 extract torrent statistics from torrent speed monitor to separate file 2014-06-02 00:31:45 +04:00
Ivan Sorokin
b50d7331c7 use post_status_update()
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:31:45 +04:00
Ivan Sorokin
eb46326d23 use set_alert_dispatch instead of timer to get an alerts from libtorrent
libtorrent allows setting a custom dispatch handler that is invoked in
libtorrent thread when new alerts are incoming. QAlertDispatcher is a
class that allows to translate these alerts to UI thread.

The concept is very simple:

1. On initialization QAlertDispatcher constructor calls set_alert_dispatch() passing
 QAlertDispatcher::dispatch as argument.

2. On deinitialization destructor calls set_alert_dispatch() passing a empty
 function. (line 25) libtorrent handles thos and switches back to queuing
 alerts in queue.

3. QAlertDispatcher::dispatch() adds alert to queue and notifies UI thread that new
 alerts are incoming. Enqueuing is done in function enqueueToMainThread().
 The invariant of class is the following:

    if alert queue is not empty, in message loop of UI thread contains a queued
    invocation of deliverSignal().

4. When message loop is pumped UI thread execute deliverSignal() function.
 It emit appropriate signal and if queue is still not empty (for example
 if slot doesn't grab alerts) rewind enqueuing to main thread.

This is a idea. But here is some details.

1. When QAlertDispatcher is destoyed, libtorrent still can call
QAlertDispatcher::dispatch a few times after destruction. This is
handled by passing a "tag". A tag is a object that references QAlertDispatch.
Tag could be invalidated. So on destruction QAlertDispatcher invalidates a tag
and then unsubscribes from alerts. When QAlertDispatcher::dispatch is called
with invalid tag it simply discard an alert.

    Therefore we could drop a few alerts during unsubscription. So we unsubscribe
    only at exit when missing some alerts is not a problem.

2. Another problem is in QBtSession::saveFastResumeData(). It pumps alert
queue synchronously. My first attempt was to destroy QAlertDispatcher
and then pump libtorrent queue. But as I was afraid of losing alerts I
supported synchronous querying of alerts in QAlertDispatcher.
(QAlertDispatcher::getPendingAlerts)

Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:31:45 +04:00
Ivan Sorokin
329b754197 cache torrent_status 2014-06-02 00:31:42 +04:00
Ivan Sorokin
bbc4080a5d fewer calls to hash() 2014-05-25 12:32:09 +04:00
sledgehammer999
659e0b7fef Fix tracker announcing problem(hit-and-run) when many torrents are being active. Closes #1571 2014-05-15 21:37:31 +03:00
sledgehammer999
9714b2ede9 Fix weird ratio values when torrent was imported or downloaded history was lost due to crash. 2014-05-05 21:30:15 +03:00
Vladimir Golovnev (Glassez)
ce3aac5f9d Fix functions and macros using to support both Qt4 and Qt5. 2014-05-02 00:00:03 +03:00
sledgehammer999
77329a2609 Launch external programs async and don't block. Closes #1252. 2014-01-26 14:28:58 +02:00
Nick Tiskov
237420546b Update QBtSession
Guaranteed to accept strings with native and qt-style separators; guaranteed to use qt-style separators internally, guaranteed to call libtorrent API with native separators
2014-01-22 19:37:27 +04:00
Nick Tiskov
1334386a1b Rework fsutils class to only use Qt-style separators
fsutils methods are guaranteed to accept strings with both native and qt-style separators and return strings with qt-style separators where appropriate
2014-01-22 19:37:24 +04:00
sledgehammer999
ceba1dc734 Don't count paused torrents for the autoshutdown. Closes #1280. 2014-01-16 16:17:10 +02:00
Nick Tiskov
d9ee9c7b0f Show actual protocol for listen_succeeded_alert and listen_failed_alert log messages.
Delete protocol mentioning from setListeningPort
2014-01-08 14:06:26 +04:00
Konstantin Goncharik
a2b3ad7958 In qbtsession.cpp exception made caught by reference 2014-01-04 01:24:32 +08:00
sledgehammer999
423d60cced Delete temporary after they aren't needed. Closes #1188. 2014-01-02 22:43:17 +02:00
arvidn
c1c824bcf7 don't use deprecated libtorrent functions 2014-01-01 10:04:22 -08:00
arvidn
3b4f9d2eeb fix libtorrent 1.0 compatibility 2013-12-31 17:00:14 -08:00
sledgehammer999
b0e8c1139f Merge pull request #1109 from doadin/patch-1
Fix Typo
2013-11-23 05:07:29 -08:00
sledgehammer999
e637ff188c Output a more generic message when blocking IPs and don't use italics in the log. 2013-11-23 13:30:50 +02:00
sledgehammer999
475aa6aad8 Merge pull request #1105 from Gelmir/stats
Add statistics dialog
2013-11-21 06:38:07 -08:00
sledgehammer999
8d04b04aae Revert "Don't prefer TCP connections over uTP."
This reverts commit a052963775.
2013-11-20 00:30:00 +02:00
doadin
f7dc57ee97 Fix Typo 2013-11-18 16:38:43 -05:00
Nick Tiskov
687e7a1343 Collect and save alltime UL/DL samples 2013-11-17 02:05:44 +04:00
sledgehammer999
0da5c8be3a Fix typo again. 2013-10-24 01:57:57 +03:00
sledgehammer999
27d72bd9bf Fix 'append label to save path' with magnet links. 2013-10-23 23:58:42 +03:00
sledgehammer999
b4dca951b2 Drop libtorrent 0.15.x support. 2013-10-23 22:19:58 +03:00
sledgehammer999
585954c988 Fix typo. 2013-10-23 22:19:55 +03:00
sledgehammer999
1c128c65f0 Don't use deprecated function when adding magnets. 2013-10-22 22:29:25 +03:00
sledgehammer999
e50d5611f8 Merge pull request #1007 from Gelmir/fix_showrss
Fix RSS items not being marked read when the item is a magnet link.
2013-10-20 08:22:00 -07:00
sledgehammer999
18b9de831f Turn off the scheduler when the user manually changes the rate limits mode. 2013-10-20 14:18:47 +03:00
Nick Tiskov
1341b7ea78 Fix RSS items not being marked read when the item is a magnet link. 2013-10-20 00:59:36 +04:00
sledgehammer999
ff789fc493 Show external IP in the log. Closes #968. 2013-10-13 23:19:15 +03:00
sledgehammer999
e08ae6b668 Fix magnet metadata loading. Update the queue and save_path correctly in all use cases. 2013-10-09 23:34:00 +03:00
sledgehammer999
14310f9b05 Improve loading of magnet metadata in the background.
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2013-10-06 13:49:23 +03:00
sledgehammer999
1e802f2090 Really fix compilation with 0.15.x. 2013-10-01 22:57:51 +03:00
sledgehammer999
c311080d8d Fix compilation with libtorrent 0.15.x. 2013-10-01 18:52:25 +03:00
sledgehammer999
6a45e9dbd7 Don't save resume data when torrent has an error. Prevents removing possibly useful .fastresume file and writing garbage. 2013-10-01 01:57:35 +03:00
sledgehammer999
a1a5fb065e Backup/recover torrent persistent data into each individual .fastresume file. This should mitigate the problem of users losing their torrents' settings/savepath/label after qbt wasn't shutdown cleanly. 2013-10-01 01:57:34 +03:00