Commit graph

73 commits

Author SHA1 Message Date
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
a361c0ea03 Use the torrent_status for the queue_position too. 2014-06-04 20:26:23 +03:00
sledgehammer999
27c641ffaa Rework the GUI code for private torrents. 2014-06-04 00:49:03 +03:00
sledgehammer999
a6fa27467f Fix previous commits. 2014-06-03 21:19:25 +03:00
Ivan Sorokin
329b754197 cache torrent_status 2014-06-02 00:31:42 +04:00
Vladimir Golovnev (Glassez)
ce3aac5f9d Fix functions and macros using to support both Qt4 and Qt5. 2014-05-02 00:00:03 +03:00
Nick Tiskov
32b90a7b6d Update QTorrentHandle
Guaranteed to accept strings with both native and qt-style separators; guaranteed to use native separators with libtorrent API
2014-01-22 19:37:26 +04:00
Konstantin Goncharik
bc22447a6a In qtorrenthandle.cpp exception made caught by reference 2014-01-04 01:19:30 +08:00
arvidn
c1c824bcf7 don't use deprecated libtorrent functions 2014-01-01 10:04:22 -08:00
sledgehammer999
b4dca951b2 Drop libtorrent 0.15.x support. 2013-10-23 22:19:58 +03:00
sledgehammer999
6bea659d50 Fix ETA calculation when some files are downloaded and marked afterwards as 'do not download'. 2013-09-01 17:01:11 +03:00
sledgehammer999
7d4a3e007e Merge pull request #711 from constantined/unwanted-fix
Make possible to move file to .unwanted directory after downloading
2013-07-27 09:24:26 -07:00
sledgehammer999
82a0c4585c Merge pull request #622 from john-peterson/column
Adding "Save path" column
2013-07-06 07:29:33 -07:00
constantined
4ec176b683 Make possible to move file to .unwanted directory after downloading 2013-07-01 12:47:24 +03:00
sledgehammer999
22e2bafa7a Fix compilation with libtorrent 1.x.x v2 2013-06-08 18:21:15 +03:00
sledgehammer999
94b58ca229 Fix compilation with libtorrent 1.x.x. 2013-05-07 22:57:18 +03:00
John Peterson
d1c3a07ba6 Adding "Save path" column
because it's useful when moving files

It's the same path as in properties because that's consistent
2013-05-01 09:05:14 +02:00
sledgehammer999
0fa0be2d0e Pass the correct flag in torrent_handle::status for libtorrent > 0.15 2013-03-10 17:08:40 +02:00
BotanEgg
bb11d11a72 Itr cache 2012-07-14 06:28:23 +08:00
Константин Гончарик
abf8c179fc Use preincrement for iterators instead of postincrement 2012-07-13 21:48:19 +03:00
Christophe Dumez
2747481816 Code clean up 2012-07-02 19:57:16 +03:00
Christophe Dumez
02c4be4eaa Fix "Open destination folder" functionality to consider torrent root folder 2012-07-02 19:51:26 +03:00
Christophe Dumez
85d2fd8ce0 Fix torrent availability computation 2012-06-28 18:10:22 +03:00
Christophe Dumez
23848be6eb Fix compilation error with libtorrent v0.15 2012-05-20 16:37:22 +03:00
Christophe Dumez
0f291629cc Move FileSystem utility functions out of misc.h
Use new fs_utils.h instead.
2012-05-16 21:19:05 +03:00
Christophe Dumez
c502edf9e1 Brand new torrent addition dialog 2012-05-15 19:57:31 +03:00
Christophe Dumez
b1f1fbf114 Optimize QTorrentHandle 2012-02-21 20:12:04 +02:00
Christophe Dumez
06ccae591e Coding style changes 2012-02-20 21:32:58 +02:00
Christophe Dumez
a8a7b61ea9 Coding style clean up 2012-02-20 19:30:53 +02:00
Christophe Dumez
a53a70742d Drop support for libtorrent v0.14.x 2012-02-18 16:44:20 +02:00
Christophe Dumez
0c9dbc15f9 Remove misc::time_tToQString() 2012-02-18 15:37:51 +02:00
Christophe Dumez
fb60a6489b Fix potential bug when moving single file torrents to tmp folder (closes #932861) 2012-02-15 21:13:42 +02:00
Christophe Dumez
f6b7b8bd6e Get rid of libboost-filesystem dependency if libtorrent >= v0.16.x is used 2011-10-25 20:56:54 +03:00
Christophe Dumez
ce6348bc32 Code clean up 2011-09-25 15:04:51 +03:00
Christophe Dumez
02fbd6a135 Fix compilation warnings in smtp.h (cgreco) 2011-06-05 16:08:30 +00:00
Christophe Dumez
7381b0dcf6 Code clean up 2011-04-23 17:20:44 +00:00
Christophe Dumez
8589eb7c0f Code optimization 2011-04-21 18:57:43 +00:00
Christophe Dumez
284fbf5512 Code clean up 2011-04-21 15:16:54 +00:00
Christophe Dumez
0ead6f72c6 Code optimization 2011-04-17 15:00:48 +00:00
Christophe Dumez
ea433c0619 Fix error in last commit 2011-04-17 10:36:50 +00:00
Christophe Dumez
8847df60e1 Fix another deprecation warning with libtorrent v0.16 2011-04-17 10:36:28 +00:00
Christophe Dumez
3995af6489 Initial port to libtorrent v0.16 2011-04-17 10:29:44 +00:00
Christophe Dumez
4412476109 Started to fix compilation with libtorrent v0.16 2011-04-16 20:08:32 +00:00
Christophe Dumez
fd8157f6ba Do not delete unwanted files that were already present when adding the torrent 2011-04-10 15:00:27 +00:00
Christophe Dumez
09da69918e Make sure the .unwanted folder is removed on soft deletion 2011-03-13 09:28:27 +00:00
Christophe Dumez
d6997e7833 Fix encoding problem in torrent moving code 2011-01-28 17:05:44 +00:00
Christophe Dumez
5c8dd9f0fb Performance improvement on ARM 2011-01-25 17:01:09 +00:00
Christophe Dumez
e931209860 Fix possible crash on adding magnet links 2011-01-12 16:53:11 +00:00
Christophe Dumez
355e776852 Fix deprecation warnings 2011-01-08 13:48:29 +00:00
Christophe Dumez
c1aec8671a Added back removal of uneeded files on torrent deletion (but not do remove the ones that are complete) 2011-01-08 13:41:15 +00:00