schedule_reopen takes &self (#10192)

This commit is contained in:
Luis Cossío
2026-09-03 12:39:00 +02:00
committed by timvisee
parent 82ce673c5e
commit 85ea29c220
5 changed files with 8 additions and 16 deletions
@@ -63,7 +63,7 @@ where
}
fn schedule_reopen<F: FnOnce(&Path) -> Option<FileInfo>>(
&mut self,
&self,
get_file_info: F,
) -> UioResult<()> {
self.schedule_reopen_impl(get_file_info)
@@ -89,7 +89,7 @@ where
}
pub(super) fn schedule_reopen_impl<F: FnOnce(&Path) -> Option<FileInfo>>(
&mut self,
&self,
get_file_info: F,
) -> UioResult<()> {
let Some(file_info) = get_file_info(&self.remote_path) else {
@@ -109,18 +109,19 @@ where
/// apply.
///
/// [`UniversalRead::schedule_reopen`]: crate::universal_io::UniversalRead::schedule_reopen
pub(super) fn schedule_reopen_with_len(&mut self, known_len: Option<u64>) -> UioResult<()> {
pub(super) fn schedule_reopen_with_len(&self, known_len: Option<u64>) -> UioResult<()> {
// Wait for scheduled prefill, if any.
//
// warn: this will do a length request if uninit, but when using a
// cached fs to create the file it should never be uninit.
self.init_state()?;
let mut state = self.state.lock();
let State::Ready {
remote,
local,
scheduled_reopen,
} = self.state.get_mut()
} = &mut *state
else {
unreachable!("init_state drives state to Ready");
};
@@ -186,15 +187,6 @@ where
}
};
// Re-borrow the state: `open_remote` above needs `&self`.
let State::Ready {
remote: _,
local: _,
scheduled_reopen,
} = self.state.get_mut()
else {
unreachable!("state was Ready above");
};
*scheduled_reopen = Some(new_scheduled_reopen);
Ok(())
@@ -595,7 +595,7 @@ mod tests_mod {
#[test]
fn reopen_schedule_missing_from_snapshot_errors() {
let scn = Scenario::new(BLOCK_SIZE);
let mut cache = scn.open::<R>(PREFILL);
let cache = scn.open::<R>(PREFILL);
let err = cache.schedule_reopen(|_| None).unwrap_err();
assert_matches!(err, UniversalIoError::NotFound { .. });
@@ -78,7 +78,7 @@ pub trait UniversalRead: Sized + Debug + Send + Sync {
/// [`CachedReadFs`]: crate::universal_io::CachedReadFs
/// [`DiskCache`]: crate::universal_io::DiskCache
fn schedule_reopen<F: FnOnce(&Path) -> Option<FileInfo>>(
&mut self,
&self,
get_file_info: F,
) -> UioResult<()> {
let _ = get_file_info;
@@ -118,7 +118,7 @@ where
#[inline]
fn schedule_reopen<F: FnOnce(&Path) -> Option<FileInfo>>(
&mut self,
&self,
get_file_info: F,
) -> UioResult<()> {
self.0.schedule_reopen(get_file_info)