Skip to content

Commit

Permalink
Adjust to changes in git-features (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 1, 2022
1 parent 7f199f0 commit 07168c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion git-ref/src/store/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Store {
/// A packed buffer which can be mapped in one version and shared as such.
/// It's updated only in one spot, which is prior to reading it based on file stamps.
/// Doing it like this has the benefit of being able to hand snapshots out to people without blocking others from updating it.
packed: packed::modifiable::SharedBufferStorage,
packed: packed::modifiable::MutableSharedBuffer,
}

mod access {
Expand Down
12 changes: 5 additions & 7 deletions git-ref/src/store/file/packed.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::path::PathBuf;

use git_features::threading::OwnShared;

use crate::store_impl::{file, packed};

impl file::Store {
Expand Down Expand Up @@ -72,19 +70,19 @@ pub mod transaction {
}

#[allow(missing_docs)]
pub type SharedBuffer = OwnShared<git_features::fs::ReloadIfChanged<packed::Buffer>>;
pub type SharedBuffer = git_features::fs::SharedSnapshot<packed::Buffer>;

pub(crate) mod modifiable {
use git_features::threading::OwnShared;

use crate::{file, packed};

pub(crate) type SharedBufferStorage = OwnShared<State>;
type State = git_features::fs::ReloadIfChangedStorage<packed::Buffer>;
pub(crate) type MutableSharedBuffer = OwnShared<State>;
type State = git_features::fs::MutableSnapshot<packed::Buffer>;

impl file::Store {
pub(crate) fn force_refresh_packed_buffer(&self) -> Result<(), packed::buffer::open::Error> {
git_features::fs::ReloadIfChanged::force_refresh(&self.packed, || {
git_features::fs::Snapshot::force_refresh(&self.packed, || {
let modified = self.packed_refs_path().metadata()?.modified()?;
self.open_packed_buffer()
.and_then(|packed| Ok(Some(modified).zip(packed)))
Expand All @@ -93,7 +91,7 @@ pub(crate) mod modifiable {
pub(crate) fn assure_packed_refs_uptodate(
&self,
) -> Result<Option<super::SharedBuffer>, packed::buffer::open::Error> {
git_features::fs::ReloadIfChanged::assure_uptodate(
git_features::fs::Snapshot::recent_snapshot(
&self.packed,
|| self.packed_refs_path().metadata().and_then(|m| m.modified()).ok(),
|| self.open_packed_buffer(),
Expand Down

0 comments on commit 07168c7

Please sign in to comment.