Skip to content

Commit

Permalink
fix: always update modification date when packed refs are forcefully …
Browse files Browse the repository at this point in the history
…reloaded. (#427)

The latter happens right after the file was written, which means we
definitely have to update our modification date or else the buffer
will be read again next time somebody asks for an up-to-date version.

The ordering of operations is such that at worst, the buffer is loaded
again instead of keeping an outdated version of it, which would happen
if the metadata is read afterwards.
  • Loading branch information
Byron committed Aug 1, 2022
1 parent 7a8c8f3 commit 1d20035
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions git-ref/src/store/file/packed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub(crate) mod modifiable {
/// but fears the change is not picked up due to lack of precision in fstat mtime calls.
pub(crate) fn force_refresh_packed_buffer(&self) -> Result<(), packed::buffer::open::Error> {
let mut state = get_mut(&self.packed);
state.modified = self.packed_refs_path().metadata()?.modified()?.into();
state.buffer = self.open_packed_buffer()?.map(OwnShared::new);
Ok(())
}
Expand Down

0 comments on commit 1d20035

Please sign in to comment.