Skip to content

Commit

Permalink
fix access metadata, assert backward logic that caused panic
Browse files Browse the repository at this point in the history
Signed-off-by: Brian L. Troutwine <[email protected]>
  • Loading branch information
blt committed Oct 28, 2024
1 parent 78d1605 commit 24877e8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lading/src/generator/file_gen/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ impl File {
/// TODO these need to modify access time et al
pub fn open(&mut self, now: Tick) {
self.advance_time(now);
if now > self.access_tick {
self.access_tick = now;
self.status_tick = now;
}

self.open_handles += 1;
}
Expand All @@ -109,7 +113,7 @@ impl File {
self.advance_time(now);

assert!(
self.open_handles == 0,
self.open_handles > 0,
"Attempted to close a file with no open handles"
);
self.open_handles -= 1;
Expand Down Expand Up @@ -146,10 +150,12 @@ impl File {
/// will be advanced, meaning `modified_tick` may update.
pub fn read(&mut self, request: u64, now: Tick) {
self.advance_time(now);
if now > self.access_tick {
self.access_tick = now;
self.status_tick = now;
}

self.bytes_read = self.bytes_read.saturating_add(request);
self.access_tick = now;
self.status_tick = now;
}

/// Run the clock forward in the `File`.
Expand Down

0 comments on commit 24877e8

Please sign in to comment.