summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-07-22 13:34:19 -0400
committerEdward Thomson <ethomson@github.com>2016-08-04 15:12:04 -0400
commit27051d4e3134e53096b10089654a965064a77403 (patch)
tree8954ca3d25e96ebaf252d4e05de78f74ca46b591 /src/fileops.c
parent8f09a98e1809dcdfd9d25b8268657bac4d942e6a (diff)
downloadlibgit2-ethomson/refresh_objects.tar.gz
odb: only freshen pack files every 2 secondsethomson/refresh_objects
Since writing multiple objects may all already exist in a single packfile, avoid freshening that packfile repeatedly in a tight loop. Instead, only freshen pack files every 2 seconds.
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/fileops.c b/src/fileops.c
index ce64934ea..fcc0301f9 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -837,16 +837,13 @@ int git_futils_cp(const char *from, const char *to, mode_t filemode)
return cp_by_fd(ifd, ofd, true);
}
-int git_futils_touch(const char *path)
+int git_futils_touch(const char *path, time_t *when)
{
struct p_timeval times[2];
- time_t now = time(NULL);
int ret;
- times[0].tv_sec = now;
- times[0].tv_usec = 0;
- times[1].tv_sec = now;
- times[1].tv_usec = 0;
+ times[0].tv_sec = times[1].tv_sec = when ? *when : time(NULL);
+ times[0].tv_usec = times[1].tv_usec = 0;
ret = p_utimes(path, times);