@@ -838,6 +838,17 @@ static void loose_backend__stream_free(git_odb_stream *_stream)
838838 git__free (stream );
839839}
840840
841+ static int filebuf_flags (loose_backend * backend )
842+ {
843+ int flags = GIT_FILEBUF_TEMPORARY |
844+ (backend -> object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT );
845+
846+ if (backend -> fsync_object_files )
847+ flags |= GIT_FILEBUF_FSYNC ;
848+
849+ return flags ;
850+ }
851+
841852static int loose_backend__stream (git_odb_stream * * stream_out , git_odb_backend * _backend , git_off_t length , git_otype type )
842853{
843854 loose_backend * backend ;
@@ -864,9 +875,7 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_
864875 stream -> stream .mode = GIT_STREAM_WRONLY ;
865876
866877 if (git_buf_joinpath (& tmp_path , backend -> objects_dir , "tmp_object" ) < 0 ||
867- git_filebuf_open (& stream -> fbuf , tmp_path .ptr ,
868- GIT_FILEBUF_TEMPORARY |
869- (backend -> object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT ),
878+ git_filebuf_open (& stream -> fbuf , tmp_path .ptr , filebuf_flags (backend ),
870879 backend -> object_file_mode ) < 0 ||
871880 stream -> stream .write ((git_odb_stream * )stream , hdr , hdrlen ) < 0 )
872881 {
@@ -894,9 +903,7 @@ static int loose_backend__write(git_odb_backend *_backend, const git_oid *oid, c
894903 header_len = git_odb__format_object_header (header , sizeof (header ), len , type );
895904
896905 if (git_buf_joinpath (& final_path , backend -> objects_dir , "tmp_object" ) < 0 ||
897- git_filebuf_open (& fbuf , final_path .ptr ,
898- GIT_FILEBUF_TEMPORARY |
899- (backend -> object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT ),
906+ git_filebuf_open (& fbuf , final_path .ptr , filebuf_flags (backend ),
900907 backend -> object_file_mode ) < 0 )
901908 {
902909 error = -1 ;
0 commit comments