Conversation
This reverts commit da182c8.
Contributor
There was a problem hiding this comment.
Pull request overview
Reverts a prior optimization to the fix_end_of_file hook implementation in crates/prek, restoring the earlier approach for determining file size and scanning for trailing line endings.
Changes:
- Switches file size detection back to
metadata().len()and moves EOF length detection intofind_last_non_ending. - Restores explicit
flush()/shutdown()calls after certain file modifications. - Reintroduces per-call heap allocation for the scan buffer in
find_last_non_ending.
Comment on lines
+80
to
84
| let data_len = reader.seek(SeekFrom::End(0)).await?; | ||
| if data_len == 0 { | ||
| return Ok((None, None)); | ||
| } | ||
|
|
| let mut read_len = 0; | ||
| let mut next_char = 0; | ||
| let mut buf = [0u8; MAX_SCAN_SIZE]; | ||
| let mut buf = vec![0u8; MAX_SCAN_SIZE]; |
Comment on lines
+74
to
78
| async fn find_last_non_ending<T>(reader: &mut T) -> Result<(Option<u64>, Option<&str>)> | ||
| where | ||
| T: AsyncRead + AsyncSeek + Unpin, | ||
| { | ||
| const MAX_SCAN_SIZE: usize = 4 * 1024; // 4KB |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1794 +/- ##
==========================================
+ Coverage 91.39% 91.77% +0.38%
==========================================
Files 98 98
Lines 20037 20039 +2
==========================================
+ Hits 18313 18391 +78
+ Misses 1724 1648 -76 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reverts commit da182c8.