libalpm: finalize tempfile if destfile doesn't exist
On setup we move the termfile into the temp download dir to resume downloads. We don't move these back losing any tempfiles we already had.
This commit is contained in:
parent
6fcecbd08d
commit
d87dd153fc
1 changed files with 10 additions and 3 deletions
|
@ -1102,17 +1102,24 @@ static int finalize_download_locations(alpm_list_t *payloads, const char *localp
|
|||
ASSERT(payloads != NULL, return -1);
|
||||
ASSERT(localpath != NULL, return -1);
|
||||
alpm_list_t *p;
|
||||
struct stat st;
|
||||
int returnvalue = 0;
|
||||
for(p = payloads; p; p = p->next) {
|
||||
struct dload_payload *payload = p->data;
|
||||
const char *filename;
|
||||
const char *filename = NULL;
|
||||
|
||||
if(payload->destfile_name) {
|
||||
if(payload->destfile_name && stat(payload->destfile_name, &st) == 0) {
|
||||
filename = payload->destfile_name;
|
||||
} else {
|
||||
} else if(stat(payload->tempfile_name, &st) == 0) {
|
||||
filename = payload->tempfile_name;
|
||||
}
|
||||
|
||||
/* if neither file exists then the download failed and logged an error for us */
|
||||
if(!filename) {
|
||||
returnvalue = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
int ret = move_file(filename, localpath);
|
||||
|
||||
if(ret == -1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue