repo

List, download and sync packs with remote repositories
Log | Files | Refs

commit 849be1f67dcdad023ac817558bf918606a3acf35
parent d9c5e6e1e01b02087fc1a6c209bcf0c857b91eb6
Author: z3bra <willyatmailoodotorg>
Date:   Fri Dec 16 02:41:37 +0100

Only download files when needed

Diffstat:
repo.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/repo.c b/repo.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <string.h> #include <sys/queue.h> +#include <sys/stat.h> +#include <sys/types.h> #include <unistd.h> #include <curl/curl.h> @@ -142,6 +144,7 @@ main (int argc, char *argv[]) char cfgfile[PATH_MAX] = DEFCFGFILE; char fn[PATH_MAX], url[PATH_MAX]; FILE *fd; + struct stat sb; struct packs plist; struct repos rlist; struct pack *p = NULL; @@ -201,14 +204,19 @@ main (int argc, char *argv[]) TAILQ_FOREACH(p, &plist, entries) { if (!strncmp(p->name, n, PATH_MAX)) { snprintf(fn, PATH_MAX, "%s/%s", DEFLOCALREPO, basename(p->url)); + if (!stat(fn, &sb)) { + puts(fn); + continue; + } + fd = fopen(fn, "w"); if (!fd) { perror(fn); - continue; + exit(1); } download(p->url, fd); - puts(fn); fclose(fd); + puts(fn); break; } }