-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | shared.c | 1 | ||||
-rw-r--r-- | ui-repolist.c | 16 |
3 files changed, 14 insertions, 4 deletions
@@ -63,2 +63,3 @@ struct cgit_repo { int enable_log_linecount; + time_t mtime; }; @@ -62,2 +62,3 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->readme = NULL; + ret->mtime = -1; return ret; diff --git a/ui-repolist.c b/ui-repolist.c index cf27cb3..aa743bf 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -34,3 +34,8 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) struct stat s; + struct cgit_repo *r = (struct cgit_repo *)repo; + if (repo->mtime != -1) { + *mtime = repo->mtime; + return 1; + } path = fmt("%s/%s", repo->path, ctx.cfg.agefile); @@ -38,2 +43,3 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) *mtime = read_agefile(path); + r->mtime = *mtime; return 1; @@ -42,7 +48,9 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); - if (stat(path, &s) == 0) { + if (stat(path, &s) == 0) *mtime = s.st_mtime; - return 1; - } - return 0; + else + *mtime = 0; + + r->mtime = *mtime; + return (r->mtime != 0); } |