Cache for multi file torrents.
More...
#include <multifilecache.h>
|
| MultiFileCache (Torrent &tor, const QString &tmpdir, const QString &datadir, bool custom_output_name) |
|
void | changeOutputPath (const QString &outputpath) override |
|
void | changeTmpDir (const QString &ndir) override |
|
void | close () override |
|
void | create () override |
|
Job * | deleteDataFiles () override |
|
Uint64 | diskUsage () override |
|
bool | getMountPoints (QSet< QString > &mps) override |
|
QString | getOutputPath () const override |
|
bool | hasMissingFiles (QStringList &sl) override |
|
void | loadFileMap () override |
|
PieceData::Ptr | loadPiece (Chunk *c, Uint32 off, Uint32 length) override |
|
Job * | moveDataFiles (const QMap< TorrentFileInterface *, QString > &files) override |
|
Job * | moveDataFiles (const QString &ndir) override |
|
void | moveDataFilesFinished (const QMap< TorrentFileInterface *, QString > &files, Job *job) override |
|
void | moveDataFilesFinished (Job *job) override |
|
void | open () override |
|
PieceData::Ptr | preparePiece (Chunk *c, Uint32 off, Uint32 length) override |
|
void | preparePreallocation (PreallocationThread *prealloc) override |
|
void | saveFileMap () override |
|
void | savePiece (PieceData::Ptr piece) override |
|
| Cache (Torrent &tor, const QString &tmpdir, const QString &datadir) |
|
void | checkMemoryUsage () |
|
void | clearPieces (Chunk *c) |
|
QString | getDataDir () const |
| Get the datadir.
|
|
bool | hasExistingFiles () const |
| See if the download has existing files.
|
|
bool | isStorageMounted (QStringList &missing) |
| Is the storage mounted ?
|
|
void | loadMountPoints () |
|
|
static bool | mappedModeAllowed () |
|
static bool | preallocateFully () |
|
static bool | preallocationEnabled () |
|
static void | setPreallocateFully (bool on) |
|
static void | setPreallocationEnabled (bool on) |
|
typedef QMultiMap< Chunk *, PieceData::Ptr > | PieceCache |
|
void | cleanupPieceCache () |
|
void | clearPieceCache () |
|
PieceData::Ptr | findPiece (Chunk *c, Uint32 off, Uint32 len, bool read_only) |
|
void | insertPiece (Chunk *c, PieceData::Ptr p) |
|
void | saveMountPoints (const QSet< QString > &mp) |
|
QString | datadir |
|
Uint32 | mmap_failures |
|
QSet< QString > | mount_points |
|
PieceCache | piece_cache |
|
bool | preexisting_files |
|
QString | tmpdir |
|
Torrent & | tor |
|
- Author
- Joris Guisson This class manages a multi file torrent cache. Everything gets stored in the correct files immediately.
Definition at line 57 of file multifilecache.h.
◆ changeOutputPath()
void bt::MultiFileCache::changeOutputPath |
( |
const QString & |
outputpath | ) |
|
|
overridevirtual |
Changes output path. All data files should already been moved. This just modifies the datadir variable.
- Parameters
-
outputpath | New output path |
Implements bt::Cache.
◆ changeTmpDir()
void bt::MultiFileCache::changeTmpDir |
( |
const QString & |
ndir | ) |
|
|
overridevirtual |
Changes the tmp dir. All data files should already been moved. This just modifies the tmpdir variable.
- Parameters
-
Reimplemented from bt::Cache.
◆ close()
void bt::MultiFileCache::close |
( |
| ) |
|
|
overridevirtual |
Close the cache file(s).
Implements bt::Cache.
◆ create()
void bt::MultiFileCache::create |
( |
| ) |
|
|
overridevirtual |
Create all the data files to store the data.
Implements bt::Cache.
◆ deleteDataFiles()
Job* bt::MultiFileCache::deleteDataFiles |
( |
| ) |
|
|
overridevirtual |
Delete all data files, in case of multi file torrents empty directories should also be deleted.
- Returns
- The job doing the delete
Implements bt::Cache.
◆ diskUsage()
Uint64 bt::MultiFileCache::diskUsage |
( |
| ) |
|
|
overridevirtual |
Get the number of bytes all the files of this torrent are currently using on disk.
Implements bt::Cache.
◆ getMountPoints()
bool bt::MultiFileCache::getMountPoints |
( |
QSet< QString > & |
mps | ) |
|
|
overridevirtual |
Determine the mount points of all the files in this torrent
- Returns
- bool True if we can, false if not
Implements bt::Cache.
◆ getOutputPath()
QString bt::MultiFileCache::getOutputPath |
( |
| ) |
const |
|
overridevirtual |
Get the actual output path.
- Returns
- The output path
Implements bt::Cache.
◆ hasMissingFiles()
bool bt::MultiFileCache::hasMissingFiles |
( |
QStringList & |
sl | ) |
|
|
overridevirtual |
Test all files and see if they are not missing. If so put them in a list
Implements bt::Cache.
◆ loadFileMap()
void bt::MultiFileCache::loadFileMap |
( |
| ) |
|
|
overridevirtual |
Load the file map of a torrent. If it doesn't exist, it needs to be created.
Implements bt::Cache.
◆ loadPiece()
PieceData::Ptr bt::MultiFileCache::loadPiece |
( |
Chunk * |
c, |
|
|
Uint32 |
off, |
|
|
Uint32 |
length |
|
) |
| |
|
overridevirtual |
Load a piece into memory. If something goes wrong, an Error should be thrown.
- Parameters
-
c | The Chunk |
off | The offset of the piece |
length | The length of the piece |
- Returns
- Pointer to the data
Implements bt::Cache.
◆ moveDataFiles() [1/2]
Move some files to a new location
- Parameters
-
files | Map of files to move and their new location |
- Returns
- Job The job doing the move
Reimplemented from bt::Cache.
◆ moveDataFiles() [2/2]
Job* bt::MultiFileCache::moveDataFiles |
( |
const QString & |
ndir | ) |
|
|
overridevirtual |
Move the data files to a new directory.
- Parameters
-
- Returns
- The job doing the move
Implements bt::Cache.
◆ moveDataFilesFinished() [1/2]
void bt::MultiFileCache::moveDataFilesFinished |
( |
const QMap< TorrentFileInterface *, QString > & |
files, |
|
|
Job * |
job |
|
) |
| |
|
overridevirtual |
The job doing moveDataFiles (with the map parameter) has finished
- Parameters
-
files | The files map with all the moves |
job | The job doing the move |
Reimplemented from bt::Cache.
◆ moveDataFilesFinished() [2/2]
void bt::MultiFileCache::moveDataFilesFinished |
( |
Job * |
job | ) |
|
|
overridevirtual |
A move of a bunch of data files has finished
- Parameters
-
job | The job doing the move |
Implements bt::Cache.
◆ open()
void bt::MultiFileCache::open |
( |
| ) |
|
|
overridevirtual |
◆ preparePiece()
PieceData::Ptr bt::MultiFileCache::preparePiece |
( |
Chunk * |
c, |
|
|
Uint32 |
off, |
|
|
Uint32 |
length |
|
) |
| |
|
overridevirtual |
Prepare a piece for writing. If something goes wrong, an Error should be thrown.
- Parameters
-
c | The Chunk |
off | The offset of the piece |
length | The length of the piece |
- Returns
- Pointer to the data
Implements bt::Cache.
◆ preparePreallocation()
Prepare disksapce preallocation
- Parameters
-
prealloc | The thread going to do the preallocation |
Implements bt::Cache.
◆ saveFileMap()
void bt::MultiFileCache::saveFileMap |
( |
| ) |
|
|
overridevirtual |
Save the file map of a torrent
Implements bt::Cache.
◆ savePiece()
void bt::MultiFileCache::savePiece |
( |
PieceData::Ptr |
piece | ) |
|
|
overridevirtual |
Save a piece to disk, will only actually save in buffered mode
- Parameters
-
Implements bt::Cache.
The documentation for this class was generated from the following file: