Reject changed nested file sizes before checkpoint replay
This commit is contained in:
1 parent
ffd84cd15b
commit
061e484001
4 files changed
+101
-30
No files matched your search
@@ -31,6 +31,10 @@ pub(super) struct SizeRead {
|
||||
read: Option<ResourceVersion>,
|
||||
}
|
||||
|
||||
pub(super) struct RebindableSourceObservations {
|
||||
pub(super) size: Option<u64>,
|
||||
}
|
||||
|
||||
impl Call {
|
||||
pub(super) fn replay(&self, files: &mut Files, partial_source: Option<&ResourceVersion>) -> Result<(), String> {
|
||||
match self {
|
||||
@@ -105,19 +109,30 @@ impl<'a> RecordingHost<'a> {
|
||||
(count < MAX_REPLAY_CALLS).then(|| (self.files.resource_trace(), count))
|
||||
}
|
||||
|
||||
pub(super) fn source_read_is_rebindable(&self, version: &ResourceVersion) -> bool {
|
||||
let Some(calls) = &self.calls else { return false };
|
||||
pub(super) fn rebindable_source_observations(
|
||||
&self,
|
||||
version: &ResourceVersion,
|
||||
) -> Option<RebindableSourceObservations> {
|
||||
let calls = self.calls.as_ref()?;
|
||||
let mut source_reads = 0;
|
||||
let mut size_reads = 0;
|
||||
for call in calls {
|
||||
match call {
|
||||
Call::ReadSource(read) if read.expected.as_ref() == Ok(version) => source_reads += 1,
|
||||
Call::FileSize(read) if read.read.as_ref().is_some_and(|r| r.path == version.path) => size_reads += 1,
|
||||
Call::FileSize(read) if read.read.as_ref().is_some_and(|r| r.path == version.path) => {
|
||||
if read.observed != Ok(Some(version.bytes)) {
|
||||
return None;
|
||||
}
|
||||
size_reads += 1;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
source_reads == 1 && self.files.resource_trace().reads.iter()
|
||||
.filter(|read| read.path == version.path).count() == source_reads + size_reads
|
||||
let actual_reads = self.files.resource_trace().reads.iter()
|
||||
.filter(|read| read.path == version.path).count();
|
||||
(source_reads == 1 && actual_reads == source_reads + size_reads).then_some(
|
||||
RebindableSourceObservations { size: (size_reads > 0).then_some(version.bytes) },
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn files(&self) -> &Files {
|
||||
|
||||
Reference in new issue
Block a user