Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't panic when creating FileBackedHistory with usize::MAX capacity #701

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

nibon7
Copy link
Contributor

@nibon7 nibon7 commented Jan 9, 2024

This pr makes FileBackedHistory::new() return Result<FileBackedHistory> and it will not panic when passing usize::MAX as capacity.

When setting $env.config.history.max_size = -1, nushell returns an error instead of panicking.

./target/debug/nu
Error:   × error within history: History capacity too large to be addressed safely

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (9ca229d) 47.59% compared to head (eb2303b) 49.40%.
Report is 2 commits behind head on main.

❗ Current head eb2303b differs from pull request most recent head 625d7ba. Consider uploading reports for the commit 625d7ba to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #701      +/-   ##
==========================================
+ Coverage   47.59%   49.40%   +1.80%     
==========================================
  Files          47       46       -1     
  Lines        9312     8006    -1306     
==========================================
- Hits         4432     3955     -477     
+ Misses       4880     4051     -829     
Files Coverage Δ
src/history/base.rs 84.30% <100.00%> (+0.35%) ⬆️
src/history/file_backed.rs 82.70% <94.11%> (+0.68%) ⬆️
src/result.rs 0.00% <0.00%> (ø)

... and 20 files with indirect coverage changes

@nibon7 nibon7 marked this pull request as draft January 10, 2024 01:19
@nibon7 nibon7 changed the title Return error when creating FileBackendHistory with invalid capacity Return error when creating FileBackedHistory with invalid capacity Jan 10, 2024
@nibon7 nibon7 changed the title Return error when creating FileBackedHistory with invalid capacity Don't panic when creating FileBackedHistory with usize::MAX capacity Jan 21, 2024
@nibon7 nibon7 marked this pull request as ready for review January 21, 2024 13:18
@stormasm stormasm merged commit 7069448 into nushell:main Jan 25, 2024
6 checks passed
@nibon7 nibon7 deleted the history branch January 26, 2024 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants