changed error handling for empty file
This commit is contained in:
parent
5e87ac92b0
commit
3c7e79089b
11
src/cache.c
11
src/cache.c
|
@ -189,7 +189,6 @@ static int Meta_read(Cache * cf)
|
|||
return EFBIG;
|
||||
}
|
||||
|
||||
if (cf->segbc > 0) {
|
||||
/*
|
||||
* Allocate memory for all segments, and read them in
|
||||
*/
|
||||
|
@ -223,12 +222,6 @@ file!\n");
|
|||
lprintf(error, "corrupted metadata!\n");
|
||||
return EBADMSG;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Allocate one single segment for empty file to prevent segfault
|
||||
*/
|
||||
cf->seg = CALLOC(1, sizeof(Seg));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -264,11 +257,7 @@ static int Meta_write(Cache * cf)
|
|||
fwrite(&cf->content_length, sizeof(off_t), 1, fp);
|
||||
fwrite(&cf->blksz, sizeof(int), 1, fp);
|
||||
fwrite(&cf->segbc, sizeof(long), 1, fp);
|
||||
if (cf->segbc > 0) {
|
||||
fwrite(cf->seg, sizeof(Seg), cf->segbc, fp);
|
||||
} else {
|
||||
lprintf(error, "cg->seg <= 0!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Error checking for fwrite
|
||||
|
|
|
@ -345,7 +345,7 @@ void Link_set_file_stat(Link * this_link, CURL * curl)
|
|||
double cl = 0;
|
||||
curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
|
||||
curl_easy_getinfo(curl, CURLINFO_FILETIME, &(this_link->time));
|
||||
if (cl < 0) {
|
||||
if (cl <= 0) {
|
||||
this_link->type = LINK_INVALID;
|
||||
} else {
|
||||
this_link->type = LINK_FILE;
|
||||
|
|
Loading…
Reference in New Issue