mirror of
https://github.com/transmission/transmission
synced 2025-02-25 07:22:38 +00:00
(trunk libT) add a couple of hooks for the mac client to use when migrating from its earlier move-on-complete code
This commit is contained in:
parent
8d1d91499a
commit
0c53f3fa62
4 changed files with 60 additions and 4 deletions
|
@ -82,7 +82,6 @@ readOrWriteBytes( const tr_torrent * tor,
|
|||
int err = 0;
|
||||
const tr_bool doWrite = ioMode == TR_IO_WRITE;
|
||||
|
||||
assert( tor->currentDir && *tor->currentDir );
|
||||
assert( fileIndex < info->fileCount );
|
||||
assert( !file->length || ( fileOffset < file->length ) );
|
||||
assert( fileOffset + buflen <= file->length );
|
||||
|
@ -105,7 +104,7 @@ readOrWriteBytes( const tr_torrent * tor,
|
|||
|
||||
if( !fileExists )
|
||||
{
|
||||
base = tor->currentDir;
|
||||
base = tr_torrentGetCurrentDir( tor );
|
||||
|
||||
if( tr_sessionIsIncompleteFileNamingEnabled( tor->session ) )
|
||||
subpath = tr_torrentBuildPartial( tor, fileIndex );
|
||||
|
|
|
@ -44,6 +44,8 @@ struct tr_ctor
|
|||
|
||||
struct optional_args optionalArgs[2];
|
||||
|
||||
char * incompleteDir;
|
||||
|
||||
tr_file_index_t * want;
|
||||
tr_file_index_t wantSize;
|
||||
tr_file_index_t * notWant;
|
||||
|
@ -300,6 +302,13 @@ tr_ctorSetDownloadDir( tr_ctor * ctor,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
tr_ctorSetIncompleteDir( tr_ctor * ctor, const char * directory )
|
||||
{
|
||||
tr_free( ctor->incompleteDir );
|
||||
ctor->incompleteDir = tr_strdup( directory );
|
||||
}
|
||||
|
||||
int
|
||||
tr_ctorGetPeerLimit( const tr_ctor * ctor,
|
||||
tr_ctorMode mode,
|
||||
|
@ -348,6 +357,20 @@ tr_ctorGetDownloadDir( const tr_ctor * ctor,
|
|||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
tr_ctorGetIncompleteDir( const tr_ctor * ctor,
|
||||
const char ** setmeIncompleteDir )
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if( ctor->incompleteDir == NULL )
|
||||
err = 1;
|
||||
else
|
||||
*setmeIncompleteDir = ctor->incompleteDir;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
tr_ctorGetMetainfo( const tr_ctor * ctor,
|
||||
const tr_benc ** setme )
|
||||
|
@ -393,6 +416,7 @@ tr_ctorFree( tr_ctor * ctor )
|
|||
clearMetainfo( ctor );
|
||||
tr_free( ctor->optionalArgs[1].downloadDir );
|
||||
tr_free( ctor->optionalArgs[0].downloadDir );
|
||||
tr_free( ctor->incompleteDir );
|
||||
tr_free( ctor->want );
|
||||
tr_free( ctor->notWant );
|
||||
tr_free( ctor->low );
|
||||
|
|
|
@ -581,8 +581,10 @@ torrentRealInit( tr_torrent * tor, const tr_ctor * ctor )
|
|||
!tr_ctorGetDownloadDir( ctor, TR_FALLBACK, &dir ) )
|
||||
tor->downloadDir = tr_strdup( dir );
|
||||
|
||||
if( tr_ctorGetIncompleteDir( ctor, &dir ) )
|
||||
dir = tr_sessionGetIncompleteDir( session );
|
||||
if( tr_sessionIsIncompleteDirEnabled( session ) )
|
||||
tor->incompleteDir = tr_strdup( tr_sessionGetIncompleteDir( session ) );
|
||||
tor->incompleteDir = tr_strdup( dir );
|
||||
|
||||
tor->lastPieceSize = info->totalSize % info->pieceSize;
|
||||
|
||||
|
@ -793,6 +795,15 @@ tr_torrentGetDownloadDir( const tr_torrent * tor )
|
|||
return tor->downloadDir;
|
||||
}
|
||||
|
||||
const char *
|
||||
tr_torrentGetCurrentDir( const tr_torrent * tor )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
return tor->currentDir;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tr_torrentChangeMyPort( tr_torrent * tor )
|
||||
{
|
||||
|
|
|
@ -877,6 +877,16 @@ void tr_ctorSetDownloadDir( tr_ctor * ctor,
|
|||
tr_ctorMode mode,
|
||||
const char * directory );
|
||||
|
||||
/**
|
||||
* @brief Set the incompleteDir for this torrent.
|
||||
*
|
||||
* This is not a supported API call.
|
||||
* It only exists so the mac client can migrate
|
||||
* its older incompleteDir settings, and that's
|
||||
* the only place where it should be used.
|
||||
*/
|
||||
void tr_ctorSetIncompleteDir( tr_ctor * ctor, const char * directory );
|
||||
|
||||
/** Set whether or not the torrent begins downloading/seeding when created.
|
||||
(Default: not paused) */
|
||||
void tr_ctorSetPaused( tr_ctor * ctor,
|
||||
|
@ -906,6 +916,9 @@ int tr_ctorGetDownloadDir( const tr_ctor * ctor,
|
|||
tr_ctorMode mode,
|
||||
const char ** setmeDownloadDir );
|
||||
|
||||
int tr_ctorGetIncompleteDir( const tr_ctor * ctor,
|
||||
const char ** setmeIncompleteDir );
|
||||
|
||||
int tr_ctorGetMetainfo( const tr_ctor * ctor,
|
||||
const struct tr_benc ** setme );
|
||||
|
||||
|
@ -1143,6 +1156,15 @@ void tr_torrentSetDownloadDir( tr_torrent * torrent, const char * path );
|
|||
|
||||
const char * tr_torrentGetDownloadDir( const tr_torrent * torrent );
|
||||
|
||||
/**
|
||||
* This returns the the root directory of where the torrent is.
|
||||
*
|
||||
* This will usually be the downloadDir. However if the torrent
|
||||
* has an incompleteDir enabled and hasn't finished downloading
|
||||
* yet, that will be returned instead.
|
||||
*/
|
||||
const char * tr_torrentGetCurrentDir( const tr_torrent * tor );
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
|
Loading…
Reference in a new issue