diff --git a/libtransmission/resume.c b/libtransmission/resume.c index cd80b5215..bb47da5ac 100644 --- a/libtransmission/resume.c +++ b/libtransmission/resume.c @@ -500,10 +500,12 @@ loadProgress( tr_benc * dict, ***/ void -tr_torrentSaveResume( const tr_torrent * tor ) +tr_torrentSaveResume( tr_torrent * tor ) { + int err; tr_benc top; - char * filename; + char * filename; + if( !tr_isTorrent( tor ) ) return; @@ -534,7 +536,8 @@ tr_torrentSaveResume( const tr_torrent * tor ) saveRatioLimits( &top, tor ); filename = getResumeFilename( tor ); - tr_bencToFile( &top, TR_FMT_BENC, filename ); + if(( err = tr_bencToFile( &top, TR_FMT_BENC, filename ))) + tr_torrentSetLocalError( tor, "Unable to save resume file: %s", tr_strerror( err ) ); tr_free( filename ); tr_bencFree( &top ); diff --git a/libtransmission/resume.h b/libtransmission/resume.h index 1e2140878..31438cb06 100644 --- a/libtransmission/resume.h +++ b/libtransmission/resume.h @@ -45,7 +45,7 @@ uint64_t tr_torrentLoadResume( tr_torrent * tor, uint64_t fieldsToLoad, const tr_ctor * ctor ); -void tr_torrentSaveResume( const tr_torrent * tor ); +void tr_torrentSaveResume( tr_torrent * tor ); void tr_torrentRemoveResume( const tr_torrent * tor ); diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index b40e5406b..42318a9e5 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -696,7 +696,9 @@ torrentInit( tr_torrent * tor, const tr_ctor * ctor ) if( !tr_ctorGetMetainfo( ctor, &val ) ) { const char * path = tor->info.torrent; - tr_bencToFile( val, TR_FMT_BENC, path ); + const int err = tr_bencToFile( val, TR_FMT_BENC, path ); + if( err ) + tr_torrentSetLocalError( tor, "Unable to save torrent file: %s", tr_strerror( err ) ); tr_sessionSetTorrentFile( tor->session, tor->info.hashString, path ); } }