Skip to content

Commit

Permalink
Rename download_file() to download_summary().
Browse files Browse the repository at this point in the history
It is no longer used as a general purpose download function so remove
some bits and update some comments that no longer make sense.
  • Loading branch information
Jonathan Perkin committed Jul 31, 2015
1 parent 03c4ae1 commit 8530c8a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
29 changes: 11 additions & 18 deletions download.c
Expand Up @@ -36,9 +36,8 @@
int fetchTimeout = 15; /* wait 15 seconds before timeout */
size_t fetch_buffer = 1024;

/* if db_mtime == NULL, we're downloading a package, pkg_summary otherwise */
Dlfile *
download_file(char *str_url, time_t *db_mtime)
download_summary(char *str_url, time_t *db_mtime)
{
/* from pkg_install/files/admin/audit.c */
Dlfile *file;
Expand All @@ -56,28 +55,23 @@ download_file(char *str_url, time_t *db_mtime)
return NULL;

if (st.size == -1) { /* could not obtain file size */
if (db_mtime != NULL) /* we're downloading pkg_summary */
*db_mtime = 0; /* not -1, don't force update */

*db_mtime = 0; /* not -1, don't force update */
return NULL;
}

if (db_mtime != NULL) {
if (st.mtime <= *db_mtime) {
/*
* -1 used to identify return type,
* local summary up-to-date
*/
*db_mtime = -1;

fetchIO_close(f);
if (st.mtime <= *db_mtime) {
/*
* -1 used to identify return type,
* local summary up-to-date
*/
*db_mtime = -1;

return NULL;
}
fetchIO_close(f);

*db_mtime = st.mtime;
return NULL;
}

*db_mtime = st.mtime;

if ((p = strrchr(str_url, '/')) != NULL)
p++;
Expand Down Expand Up @@ -129,7 +123,6 @@ download_file(char *str_url, time_t *db_mtime)
if (file->buf[0] == '\0')
errx(EXIT_FAILURE, "empty download, exiting.\n");


fetchIO_close(f);

return file;
Expand Down
2 changes: 1 addition & 1 deletion pkgin.h
Expand Up @@ -227,7 +227,7 @@ extern FILE *tracefp;
extern Preflist **preflist;

/* download.c*/
Dlfile *download_file(char *, time_t *);
Dlfile *download_summary(char *, time_t *);
ssize_t download_pkg(char *, FILE *);
/* summary.c */
int update_db(int, char **);
Expand Down
2 changes: 1 addition & 1 deletion summary.c
Expand Up @@ -119,7 +119,7 @@ fetch_summary(char *cur_repo)
snprintf(buf, BUFSIZ, "%s/%s.%s",
cur_repo, PKG_SUMMARY, sumexts[i]);

if ((file = download_file(buf, &sum_mtime)) != NULL)
if ((file = download_summary(buf, &sum_mtime)) != NULL)
break; /* pkg_summary found and not up-to-date */

if (sum_mtime < 0) /* pkg_summary found, but up-to-date */
Expand Down

0 comments on commit 8530c8a

Please sign in to comment.