diff options
author | Edward Thomson <ethomson@github.com> | 2017-02-17 16:36:53 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2017-02-28 13:28:36 +0000 |
commit | 1229e1c4d7ea1eb4c5bcd5c0d89bc576053175db (patch) | |
tree | eaa95a9af16669ea7497dc30091b220a54404d5d /src/indexer.c | |
parent | 5a747e0c6c5170d29969eb15822c36d76dd3e4ac (diff) | |
download | libgit2-1229e1c4d7ea1eb4c5bcd5c0d89bc576053175db.tar.gz |
fsync parent directories when fsyncing
When fsync'ing files, fsync the parent directory in the case where we
rename a file into place, or create a new file, to ensure that the
directory entry is flushed correctly.
Diffstat (limited to 'src/indexer.c')
-rw-r--r-- | src/indexer.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/indexer.c b/src/indexer.c index 30c365565..9510253b5 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -1086,7 +1086,14 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) goto on_error; /* And don't forget to rename the packfile to its new place. */ - p_rename(idx->pack->pack_name, git_buf_cstr(&filename)); + if (p_rename(idx->pack->pack_name, git_buf_cstr(&filename)) < 0) + goto on_error; + + /* And fsync the parent directory if we're asked to. */ + if (git_object__synchronized_writing && + git_futils_fsync_parent(git_buf_cstr(&filename)) < 0) + goto on_error; + idx->pack_committed = 1; git_buf_free(&filename); |