fix(forge): list cache files that are saved as block numbers for cache ls
#7270
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.
Motivation
Some time ago, after this PR 4ae40da#diff-61de971a1475be0209ee9896ce71d6b3424904b26eb2ea0227d1ff23ee4e6e6bL585-L587
the rpc cache location was changed from
~/.foundry/cache/rpc/[chain]/[blockNumber]/storage.json
to
~/.foundry/cache/rpc/[chain]/[blockNumber]
However the
cache ls
function was not updated with this change.This resulted
forge cache ls
listing very old caches that are not used anymore, but ignoring the newer caches as they are not directories.Example:
Running
forge cache ls
with forge 0.2.0 (43b4e23 2024-02-25T00:21:15.546682000Z)Note that the RPC caches are ignored in above output and the total sizes are do not include them.
Solution
Don't ignore files that are numeric only in their names when listing caches.
RPC caches are included and the total size of the cache is correctly displayed as well.