From 0c0d7ba85f3d244573d356427b890de825a623e0 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 6 Dec 2021 23:04:00 -0800 Subject: [PATCH] ... --- src/torrent/add.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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); } -- 2.30.2