Skip to content

Commit f2d8955

Browse files
committed
feat: add file::Store::force_refresh_packed_buffer() to public API (#1348)
That way it's possible to explicitly refresh if the caller knows that some other operation might have invalidated the in-memory cache. The `mtime` based approach doesn't work reliably on all filesystems due to coarse granularity of time.
1 parent 44a2e00 commit f2d8955

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

gix-ref/src/store/file/packed.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ pub(crate) mod modifiable {
8484
pub(crate) type MutableSharedBuffer = OwnShared<gix_fs::SharedFileSnapshotMut<packed::Buffer>>;
8585

8686
impl file::Store {
87-
pub(crate) fn force_refresh_packed_buffer(&self) -> Result<(), packed::buffer::open::Error> {
87+
/// Forcefully reload the packed refs buffer.
88+
///
89+
/// This method should be used if it's clear that the buffer on disk has changed, to
90+
/// make the latest changes visible before other operations are done on this instance.
91+
///
92+
/// As some filesystems don't have nanosecond granularity, changes are likely to be missed
93+
/// if they happen within one second otherwise.
94+
pub fn force_refresh_packed_buffer(&self) -> Result<(), packed::buffer::open::Error> {
8895
self.packed.force_refresh(|| {
8996
let modified = self.packed_refs_path().metadata()?.modified()?;
9097
self.open_packed_buffer().map(|packed| Some(modified).zip(packed))

0 commit comments

Comments
 (0)