xbps_fetch_file: remove local file if bigger than remote and refetch.

This commit is contained in:
Juan RP 2011-06-23 00:06:50 +02:00
parent 74ce033d45
commit 5847a11570

View File

@ -233,11 +233,13 @@ xbps_fetch_file(const char *uri,
rv = -1;
goto out;
} else if (st.st_size > url_st.size) {
xbps_error_printf("Local file %s is greater than remote "
"file!\n", filename);
errno = EFBIG;
rv = -1;
goto out;
/*
* Remove local file if bigger than remote, and refetch the
* whole shit again.
*/
xbps_warn_printf("Local file %s is greater than remote, "
"removing local file and refetching...\n", filename);
(void)remove(destfile);
} else if (restart && url_st.mtime && url_st.size &&
url_st.size == st.st_size && url_st.mtime == st.st_mtime) {
/* Local and remote size/mtime match, do nothing. */