Skip to content

Commit

Permalink
fix: truncate() now works if the new size is close to the old one
Browse files Browse the repository at this point in the history
  • Loading branch information
Oakchris1955 committed Aug 31, 2024
1 parent f88942b commit a60e55b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,10 @@ where
pub fn truncate(&mut self, size: u32) -> Result<(), <Self as IOBase>::Error> {
// looks like the new truncated size would be smaller than the current one, so we just return
if size.next_multiple_of(self.fs.props.cluster_size as u32) >= self.file_size {
if size < self.file_size {
self.file_size = size;
}

return Ok(());
}

Expand Down

0 comments on commit a60e55b

Please sign in to comment.