|
|
@ -81,17 +81,21 @@ bittorrent::~bittorrent() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void bittorrent::preAllocateAllFiles(bool b) { |
|
|
|
void bittorrent::preAllocateAllFiles(bool b) { |
|
|
|
preAllocateAll = b; |
|
|
|
bool change = (preAllocateAll != b); |
|
|
|
// Reload All Torrents
|
|
|
|
if(change) { |
|
|
|
std::vector<torrent_handle> handles = s->get_torrents(); |
|
|
|
qDebug("PreAllocateAll changed, reloading all torrents!"); |
|
|
|
unsigned int nbHandles = handles.size(); |
|
|
|
preAllocateAll = b; |
|
|
|
for(unsigned int i=0; i<nbHandles; ++i) { |
|
|
|
// Reload All Torrents
|
|
|
|
QTorrentHandle h = handles[i]; |
|
|
|
std::vector<torrent_handle> handles = s->get_torrents(); |
|
|
|
if(!h.is_valid()) { |
|
|
|
unsigned int nbHandles = handles.size(); |
|
|
|
qDebug("/!\\ Error: Invalid handle"); |
|
|
|
for(unsigned int i=0; i<nbHandles; ++i) { |
|
|
|
continue; |
|
|
|
QTorrentHandle h = handles[i]; |
|
|
|
|
|
|
|
if(!h.is_valid()) { |
|
|
|
|
|
|
|
qDebug("/!\\ Error: Invalid handle"); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pauseAndReloadTorrent(h, b); |
|
|
|
} |
|
|
|
} |
|
|
|
pauseAndReloadTorrent(h, b); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1226,11 +1230,13 @@ void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) { |
|
|
|
++timeout; |
|
|
|
++timeout; |
|
|
|
} |
|
|
|
} |
|
|
|
QTorrentHandle new_h; |
|
|
|
QTorrentHandle new_h; |
|
|
|
if(full_alloc) |
|
|
|
if(full_alloc) { |
|
|
|
new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_allocate); |
|
|
|
new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_allocate); |
|
|
|
else |
|
|
|
qDebug("Using full allocation mode"); |
|
|
|
|
|
|
|
} else { |
|
|
|
new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_sparse); |
|
|
|
new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_sparse); |
|
|
|
qDebug("Using full allocation mode"); |
|
|
|
qDebug("Using sparse mode"); |
|
|
|
|
|
|
|
} |
|
|
|
// Connections limit per torrent
|
|
|
|
// Connections limit per torrent
|
|
|
|
new_h.set_max_connections(maxConnecsPerTorrent); |
|
|
|
new_h.set_max_connections(maxConnecsPerTorrent); |
|
|
|
// Uploads limit per torrent
|
|
|
|
// Uploads limit per torrent
|
|
|
|