diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-05-03 11:10:42 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-05-03 11:10:42 +0000 |
commit | 26e0b7e748badd2dd95d8b5a0743b0af5ea7f78f (patch) | |
tree | 6195e0de5591ec7093a73eb8c83bd7e547e9dac9 | |
parent | 830ae3dd9851355c82d86db2e6a22b78e88da0d7 (diff) |
Fixed bug inside hts_mirror_wait_for_next_file() that may lead to race conditions in downloaded files, leading to download several times the same file, possibly ending with "Unexpected 412/416 error" errors.
-rw-r--r-- | src/htsparse.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/htsparse.c b/src/htsparse.c index b718655..41d1797 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -3988,6 +3988,11 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct* str, htsmoduleStructExtended* int b; int n; + /* This is not supposed to hapen. */ + if (liens[ptr]->pass2 == -1) { + HTS_LOG(opt, LOG_WARNING); fprintf(opt->log, "Link is already ready %s%s"LF, urladr, urlfil); + } + /* User interaction */ ENGINE_SAVE_CONTEXT(); { @@ -3995,6 +4000,15 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct* str, htsmoduleStructExtended* } ENGINE_SET_CONTEXT(); + /* Done while processing user interactions ? */ + if (liens[ptr]->pass2 == -1) { + if ( (opt->debug>0) && (opt->log!=NULL) ) { + HTS_LOG(opt,LOG_DEBUG); fprintf(opt->log, "Link is now ready %s%s"LF, urladr, urlfil); + } + // We are ready + return 2; // goto jump_if_done; + } + // si le fichier n'est pas en backing, le mettre.. if (!back_exist(str->sback,str->opt,urladr,urlfil,savename)) { #if BDEBUG==1 |