Closed gfwilliams closed 1 year ago
We're still not being smart about where to start compaction...
jsfGetStorageStats
could maybe store the address of the first page (that's not straddled by a file) with an erased file in it, and then I believe jsfCompactInternal
should be fine to start from that
Turns out it wasn't that bad :)
Discussed here: https://github.com/espruino/BangleApps/issues/2865
Generally writes to storage are pretty safe and won't cause issues if the battery dies during a write, but if the storage is full then it has to be compacted. This can take a minute or more, during which a decent amount of power is used - and if the battery is very low then it could cause a shutdown during that process, which would cause storage corruption.
To make matters worse, if storage were very full and a file kept being changed, that could force storage be compacted multiple times.
So we need to: