1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 00:34:04 +00:00

avoid ridiculously rate divide-by-0

This commit is contained in:
Mitchell Livingston 2007-06-19 00:08:06 +00:00
parent 48c44109c9
commit a4d5dfa328
2 changed files with 7 additions and 3 deletions

View file

@ -663,7 +663,11 @@ float
tr_torrentFileCompletion ( const tr_torrent_t * tor, int fileIndex )
{
const uint64_t c = tr_torrentFileBytesCompleted ( tor, fileIndex );
return (double)c / tor->info.files[fileIndex].length;
uint64_t length = tor->info.files[fileIndex].length;
if( !length )
return 1.0;
return (double)c / length;
}
float*

View file

@ -161,8 +161,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
{
fLib = tr_init("macosx");
fTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
fDisplayedTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
fTorrents = [[NSMutableArray alloc] init];
fDisplayedTorrents = [[NSMutableArray alloc] init];
fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
fDefaults = [NSUserDefaults standardUserDefaults];