From: alex Date: Tue, 7 Dec 2021 07:04:00 +0000 (-0800) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=0c0d7ba85f3d244573d356427b890de825a623e0;p=seeder ... --- diff --git a/src/torrent/add.c b/src/torrent/add.c index 6b80dd1..ce012c8 100644 --- a/src/torrent/add.c +++ b/src/torrent/add.c @@ -77,14 +77,13 @@ static int torrent_files_resize(struct torrent *torrent_p, size_t new_size) { for(size_t i=0;ifiles->size;i++) { p = torrent_p->files->map[i]; if(p!=NULL) { - if( - ((ret = torrent_add_file_by_root(new,p))<=0) || - ((ret = torrent_add_file_by_path(new,p))<=0) - ) { + if((ret = torrent_add_file_by_root(new,p))<=0) { if(ret<0) { return -1; } - hashmap_clear(new); - hashmap_free(new); - return torrent_files_resize(torrent_p,new_size<<1); + goto resize; + } + + if(ret==0) { + if((ret = torrent_add_file_by_path(new,p))<=0) { goto resize; } } } } @@ -97,4 +96,9 @@ static int torrent_files_resize(struct torrent *torrent_p, size_t new_size) { hashmap_free(old); return 1; +resize: + if(ret<0) { return -1; } + hashmap_clear(new); + hashmap_free(new); + return torrent_files_resize(torrent_p,new_size<<1); }