Fix bug in REPL and aggregate duplicated code #157
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.
Bug in REPL
Found bug in repl, that it sends block_count to littlefs based on the file size, but in compacted image the file sze is not really the correct size hence getting error from littlefs.
This is in different than list and extract commands which not sending block_count, and when littlefs getting 0 it ignores it.
(Try run the test file I added with current master and see the failure)
Solution
Make behavior of list+extract+repl same by using same function
great side effects
having code not duplicated is less error prone...
Now also repl getting LittleFS Configuration: which was missing
Have print that tell the Image Size: size and the Input Image Size (compacted):
Have new test that catching this issue (according beyonce rule)
Now that all creation of littlefs pass through _fs_from_args it will be easier for me to implement #150
Left issue
Now REPL succeed to mount and work with compacted image, but when changing the image (with put command for example) it works but the image is being partially compacted (depends on where littlefs decide to put the data). Need design decision here what is expected behaviour, anyway I think it is different task and this one should be merged as is.