url: rename to .backup rather than unlink before wget
parent
74b5e4f535
commit
9e70b1c9c7
|
@ -83,6 +83,7 @@ int apk_url_download(const char *url, const char *file)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
char tmp[256];
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
|
@ -91,7 +92,8 @@ int apk_url_download(const char *url, const char *file)
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
setsid();
|
setsid();
|
||||||
dup2(open("/dev/null", O_RDONLY), STDIN_FILENO);
|
dup2(open("/dev/null", O_RDONLY), STDIN_FILENO);
|
||||||
unlink(file);
|
snprintf(tmp, sizeof(tmp), "%s.backup", file);
|
||||||
|
rename(file, tmp);
|
||||||
execlp("wget", "wget", "-q", "-O", file, url, NULL);
|
execlp("wget", "wget", "-q", "-O", file, url, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue