aboutsummaryrefslogtreecommitdiffstats
path: root/main/abuild/0001-abuild-fetch-retry-download-if-byte-range-is-unsuppo.patch
blob: 1bd6699d170f5633904b26de891923964d8151d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 2be7002cda0397c2df55a969968a2d5579fcb76f Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 8 Jul 2020 10:10:26 +0200
Subject: [PATCH] abuild-fetch: retry download if byte range is unsupported

fixes #10004
---
 abuild-fetch.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/abuild-fetch.c b/abuild-fetch.c
index a2c3cf2..7906704 100644
--- a/abuild-fetch.c
+++ b/abuild-fetch.c
@@ -142,7 +142,7 @@ int fetch(char *url, const char *destdir, bool insecure)
 
 	if (access(partfile, F_OK) == 0) {
 		printf("Partial download found. Trying to resume.\n");
-		add_opt(&curlcmd, "-C");
+		add_opt(&curlcmd, "--continue-at");
 		add_opt(&curlcmd, "-");
 		add_opt(&wgetcmd, "-c");
 	}
@@ -154,8 +154,16 @@ int fetch(char *url, const char *destdir, bool insecure)
 
 	/* CURLE_RANGE_ERROR (33)
 	   The server does not support or accept range requests. */
-	if (status == 33)
+	if (status == 33) {
 		unlink(partfile);
+		if( curlcmd.argc >=3) {
+			/* remove --continue-at - options */
+			curlcmd.argv[curlcmd.argc-3] = curlcmd.argv[curlcmd.argc-1];
+			curlcmd.argv[curlcmd.argc-2] = NULL;
+			curlcmd.argc -= 2;
+			status = fork_exec(curlcmd.argv, 0);
+		}
+	}
 
 	/* is we failed execute curl, then fallback to wget */
 	if (status == 201)
-- 
2.28.0