libktorrent
2.2.0
|
#include <chunkmanager.h>
Signals | |
void | corrupted (Uint32 chunk) |
void | excluded (Uint32 from, Uint32 to) |
void | included (Uint32 from, Uint32 to) |
void | updateStats () |
Public Member Functions | |
ChunkManager (Torrent &tor, const QString &tmpdir, const QString &datadir, bool custom_output_name, CacheFactory *fac) | |
Uint64 | bytesExcluded () const |
Uint64 | bytesLeft () const |
Uint64 | bytesLeftToDownload () const |
void | changeDataDir (const QString &data_dir) |
void | changeOutputPath (const QString &output_path) |
void | checkMemoryUsage () |
Remove obsolete chunks. | |
void | chunkDownloaded (unsigned int i) |
Uint32 | chunksDownloaded () const |
Uint32 | chunksExcluded () const |
Uint32 | chunksLeft () const |
bool | completed () const |
Are all not deselected chunks downloaded. | |
void | createFiles (bool check_priority=false) |
void | dataChecked (const BitSet &ok_chunks, Uint32 from, Uint32 to) |
void | debugPrintMemUsage () |
Print memory usage to log file. | |
Job * | deleteDataFiles () |
Delete all data files. | |
Uint64 | diskUsage () |
Get the current disk usage of all the files in this torrent. | |
void | dndMissingFiles () |
Set missing files as do not download. | |
void | downloadPriorityChanged (TorrentFile *tf, Priority newpriority, Priority oldpriority) |
The download priority of a file has changed. | |
void | exclude (Uint32 from, Uint32 to) |
const BitSet & | getBitSet () const |
Chunk * | getChunk (unsigned int i) |
QString | getDataDir () const |
Get the data dir. | |
const BitSet & | getExcludedBitSet () const |
Uint32 | getNumChunks () const |
Get the number of chunks into the file. | |
const BitSet & | getOnlySeedBitSet () const |
QString | getOutputPath () const |
Get the actual output path. | |
const Torrent & | getTorrent () const |
Get the torrent. | |
bool | hasExistingFiles () const |
Test if the torrent has existing files, only works the first time a torrent is loaded. | |
bool | hasMissingFiles (QStringList &sl) |
bool | haveAllChunks () const |
void | include (Uint32 from, Uint32 to) |
bool | isStorageMounted (QStringList &missing) |
Is the storage mounted ? | |
void | loadIndexFile () |
void | markExistingFilesAsDownloaded () |
Mark all existing files as downloaded. | |
Job * | moveDataFiles (const QMap< TorrentFileInterface *, QString > &files) |
Job * | moveDataFiles (const QString &ndir) |
void | moveDataFilesFinished (const QMap< TorrentFileInterface *, QString > &files, Job *job) |
void | moveDataFilesFinished (Job *job) |
Uint32 | onlySeedChunks () const |
void | preparePreallocation (PreallocationThread *prealloc) |
Uint32 | previewChunkRangeSize () const |
Get the size in chunks of the preview range for a single file torrent. | |
Uint32 | previewChunkRangeSize (const TorrentFile &tf) const |
Get the size in chunks of the preview range of a file of the torrent. | |
void | prioritise (Uint32 from, Uint32 to, Priority priority) |
void | recreateMissingFiles () |
Recreates missing files. | |
void | resetChunk (unsigned int i) |
void | start () |
void | stop () |
Static Public Member Functions | |
static void | setPreviewSizes (Uint32 audio, Uint32 video) |
Set the preview sizes for audio and video files. | |
Manages all Chunk's and the cache file, where all the chunk's are stored. It also manages a separate index file, where the position of each piece in the cache file is stored.
The chunks are stored in the cache file in the correct order. Eliminating the need for a file reconstruction algorithm for single files.
Definition at line 60 of file chunkmanager.h.
Uint64 bt::ChunkManager::bytesExcluded | ( | ) | const |
Calculates the number of bytes which have been excluded.
Uint64 bt::ChunkManager::bytesLeft | ( | ) | const |
Calculates the number of bytes left for the tracker. Does include excluded chunks (this should be used for the tracker).
Uint64 bt::ChunkManager::bytesLeftToDownload | ( | ) | const |
Calculates the number of bytes left to download.
void bt::ChunkManager::changeDataDir | ( | const QString & | data_dir | ) |
Change the data dir.
data_dir |
void bt::ChunkManager::chunkDownloaded | ( | unsigned int | i | ) |
Mark a chunk as downloaded.
i | The Chunk's index |
Uint32 bt::ChunkManager::chunksDownloaded | ( | ) | const |
Get the number of downloaded chunks
Uint32 bt::ChunkManager::chunksExcluded | ( | ) | const |
Get the number of chunks which have been excluded.
Uint32 bt::ChunkManager::chunksLeft | ( | ) | const |
Calculates the number of chunks left to download. Does not include excluded chunks.
|
signal |
A corrupted chunk has been found during uploading.
chunk | The chunk |
void bt::ChunkManager::createFiles | ( | bool | check_priority = false | ) |
Create the cache file, and index files.
check_priority | Check if priority of chunk matches that of files |
Error | When it can be created |
void bt::ChunkManager::dataChecked | ( | const BitSet & | ok_chunks, |
Uint32 | from, | ||
Uint32 | to | ||
) |
Data has been checked, and these chunks are OK. The ChunkManager will update it's internal structures
ok_chunks | The ok_chunks |
from | First chunk of the check |
to | Last chunk of the check |
void bt::ChunkManager::exclude | ( | Uint32 | from, |
Uint32 | to | ||
) |
Make sure that a range will not be downloaded.
from | First chunk in range |
to | Last chunk in range |
|
signal |
Emitted when a range of chunks has been excluded
from | First chunk in range |
to | Last chunk in range |
|
inline |
Get a BitSet of the status of all Chunks
Definition at line 226 of file chunkmanager.h.
Chunk* bt::ChunkManager::getChunk | ( | unsigned int | i | ) |
|
inline |
Get the excluded bitset
Definition at line 234 of file chunkmanager.h.
|
inline |
Get the only seed bitset.
Definition at line 242 of file chunkmanager.h.
bool bt::ChunkManager::hasMissingFiles | ( | QStringList & | sl | ) |
Test all files and see if they are not missing. If so put them in a list
bool bt::ChunkManager::haveAllChunks | ( | ) | const |
Check if we have all chunks, this is not the same as chunksLeft() == 0, it does not look at excluded chunks.
void bt::ChunkManager::include | ( | Uint32 | from, |
Uint32 | to | ||
) |
Make sure that a range will be downloaded. Does the opposite of exclude.
from | First chunk in range |
to | Last chunk in range |
|
signal |
Emitted when a range of chunks has been included back.
from | First chunk in range |
to | Last chunk in range |
void bt::ChunkManager::loadIndexFile | ( | ) |
Loads the index file.
Error | When it can be loaded |
Job* bt::ChunkManager::moveDataFiles | ( | const QMap< TorrentFileInterface *, QString > & | files | ) |
Move some data files to a new location
files | Map of files and their new location |
Job* bt::ChunkManager::moveDataFiles | ( | const QString & | ndir | ) |
Move the data files of the torrent.
ndir | The new directory |
void bt::ChunkManager::moveDataFilesFinished | ( | const QMap< TorrentFileInterface *, QString > & | files, |
Job * | job | ||
) |
A move of data files with the map has finished
files | Map of files and their new location |
job | The job doing the move |
void bt::ChunkManager::moveDataFilesFinished | ( | Job * | job | ) |
A move of data files has finished
job | The job doing the move |
Uint32 bt::ChunkManager::onlySeedChunks | ( | ) | const |
Get the number of only seed chunks.
void bt::ChunkManager::preparePreallocation | ( | PreallocationThread * | prealloc | ) |
Prepare diskspace preallocation
prealloc | The thread going to do the preallocation |
void bt::ChunkManager::prioritise | ( | Uint32 | from, |
Uint32 | to, | ||
Priority | priority | ||
) |
Make sure that a range will get priority over other chunks.
from | First chunk in range |
to | Last chunk in range |
void bt::ChunkManager::resetChunk | ( | unsigned int | i | ) |
Reset a chunk as if it were never downloaded.
i | The chunk |
void bt::ChunkManager::start | ( | ) |
Open the necessary files when the download gets started.
void bt::ChunkManager::stop | ( | ) |
Closes files when the download gets stopped.
|
signal |
Emitted when chunks get excluded or included, so that the statistics can be updated.