index-pack: Use fsync to ensure received pack data is on disk
commit7398621f670bfdd46e7400cd7d4218d8a9ed6904
authorShawn O. Pearce <spearce@spearce.org>
Wed, 27 Aug 2008 21:48:44 +0000 (27 14:48 -0700)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Wed, 27 Aug 2008 22:12:19 +0000 (28 00:12 +0200)
treec5f88e227fa5c27cb17cf2a4ba2464b1cbf1d5c3
parent0ce562626aa05792ebbbdd9688cd3c2a0418319a
index-pack: Use fsync to ensure received pack data is on disk

C Git uses fsync() to ensure that a pack file is stable on disk before
it starts to delete any other copies of the data, or before it tries
to update refs to refer to data stored in the pack.  This makes it a
lot less likely that a repository will see corruption due to refs
pointing at unavailable objects.

We now force our pack and its associated .idx file to disk before
we close the file descriptors, but after we have finished reading
and writing all of the data.  This way we can be fairly certain
a future user of the data (like a RefUpdate) always has objects.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java