summaryrefslogtreecommitdiff
path: root/src/odb_loose.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-12-13 10:35:05 -0500
committerEdward Thomson <ethomson@github.com>2017-02-28 13:27:49 +0000
commitfc27fe213c8462c8413486b8c2bfb82b25b3e7e6 (patch)
treea79105da96aab01e79661dfd88e14d2978156b1c /src/odb_loose.c
parentfc77891f6308ee4ca837cdf558969c5c457b1392 (diff)
downloadlibgit2-fc27fe213c8462c8413486b8c2bfb82b25b3e7e6.tar.gz
odb_loose: actually honor the fsync option
We've had an fsync option for a long time, but it was "ignored". Stop ignoring it.
Diffstat (limited to 'src/odb_loose.c')
-rw-r--r--src/odb_loose.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/odb_loose.c b/src/odb_loose.c
index b2e2f1fb7..8796f4bae 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -838,6 +838,17 @@ static void loose_backend__stream_free(git_odb_stream *_stream)
git__free(stream);
}
+static int filebuf_flags(loose_backend *backend)
+{
+ int flags = GIT_FILEBUF_TEMPORARY |
+ (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT);
+
+ if (backend->fsync_object_files)
+ flags |= GIT_FILEBUF_FSYNC;
+
+ return flags;
+}
+
static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, git_off_t length, git_otype type)
{
loose_backend *backend;
@@ -864,9 +875,7 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_
stream->stream.mode = GIT_STREAM_WRONLY;
if (git_buf_joinpath(&tmp_path, backend->objects_dir, "tmp_object") < 0 ||
- git_filebuf_open(&stream->fbuf, tmp_path.ptr,
- GIT_FILEBUF_TEMPORARY |
- (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT),
+ git_filebuf_open(&stream->fbuf, tmp_path.ptr, filebuf_flags(backend),
backend->object_file_mode) < 0 ||
stream->stream.write((git_odb_stream *)stream, hdr, hdrlen) < 0)
{
@@ -894,9 +903,7 @@ static int loose_backend__write(git_odb_backend *_backend, const git_oid *oid, c
header_len = git_odb__format_object_header(header, sizeof(header), len, type);
if (git_buf_joinpath(&final_path, backend->objects_dir, "tmp_object") < 0 ||
- git_filebuf_open(&fbuf, final_path.ptr,
- GIT_FILEBUF_TEMPORARY |
- (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT),
+ git_filebuf_open(&fbuf, final_path.ptr, filebuf_flags(backend),
backend->object_file_mode) < 0)
{
error = -1;