mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
possible fix for the crash in http://forum.transmissionbt.com/viewtopic.php?t=4847
This commit is contained in:
parent
d3d39fce19
commit
4c82187933
1 changed files with 17 additions and 7 deletions
|
@ -170,18 +170,28 @@ tr_metainfoMigrate( tr_handle * handle,
|
|||
size_t contentLen;
|
||||
uint8_t * content;
|
||||
|
||||
tr_mkdirp( tr_getTorrentDir( handle ), 0777 );
|
||||
getTorrentOldFilename( handle, inf, old_name, sizeof( old_name ) );
|
||||
if(( content = tr_loadFile( old_name, &contentLen )))
|
||||
{
|
||||
FILE * out = fopen( new_name, "wb+" );
|
||||
if( fwrite( content, sizeof( uint8_t ), contentLen, out ) == contentLen )
|
||||
FILE * out;
|
||||
errno = 0;
|
||||
out = fopen( new_name, "wb+" );
|
||||
if( !out )
|
||||
{
|
||||
tr_free( inf->torrent );
|
||||
inf->torrent = tr_strdup( new_name );
|
||||
tr_sessionSetTorrentFile( handle, inf->hashString, new_name );
|
||||
unlink( old_name );
|
||||
tr_nerr( inf->name, _( "Couldn't create \"%1$s\": %2$s" ), new_name, tr_strerror( errno ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fwrite( content, sizeof( uint8_t ), contentLen, out ) == contentLen )
|
||||
{
|
||||
tr_free( inf->torrent );
|
||||
inf->torrent = tr_strdup( new_name );
|
||||
tr_sessionSetTorrentFile( handle, inf->hashString, new_name );
|
||||
unlink( old_name );
|
||||
}
|
||||
fclose( out );
|
||||
}
|
||||
fclose( out );
|
||||
}
|
||||
|
||||
tr_free( content );
|
||||
|
|
Loading…
Reference in a new issue