diff options
| author | Edward Thomson <ethomson@github.com> | 2016-12-15 14:49:43 -0600 |
|---|---|---|
| committer | Edward Thomson <ethomson@github.com> | 2017-02-28 13:28:36 +0000 |
| commit | eb56ed81afd0091a0616a1099d7792f12e0726f6 (patch) | |
| tree | 03b958ff1b7d2f6dc51ba1eb40fc0949e387aba5 /src/refdb_fs.c | |
| parent | af3dcb0e50416ce08bcfed7524b073b980180ef2 (diff) | |
| download | libgit2-eb56ed81afd0091a0616a1099d7792f12e0726f6.tar.gz | |
refdb_fs: optionally fsync packed refs
Diffstat (limited to 'src/refdb_fs.c')
| -rw-r--r-- | src/refdb_fs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 11ff96843..fac5ba5d1 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -994,15 +994,18 @@ static int packed_write(refdb_fs_backend *backend) { git_sortedcache *refcache = backend->refcache; git_filebuf pack_file = GIT_FILEBUF_INIT; - int error; + int error, open_flags = 0; size_t i; /* lock the cache to updates while we do this */ if ((error = git_sortedcache_wlock(refcache)) < 0) return error; + if (git_object__synchronized_writing) + open_flags = GIT_FILEBUF_FSYNC; + /* Open the file! */ - if ((error = git_filebuf_open(&pack_file, git_sortedcache_path(refcache), 0, GIT_PACKEDREFS_FILE_MODE)) < 0) + if ((error = git_filebuf_open(&pack_file, git_sortedcache_path(refcache), open_flags, GIT_PACKEDREFS_FILE_MODE)) < 0) goto fail; /* Packfiles have a header... apparently |
