refactor: improve compaction logic#373
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #373 +/- ##
==========================================
+ Coverage 62.59% 62.64% +0.05%
==========================================
Files 37 37
Lines 3240 3234 -6
==========================================
- Hits 2028 2026 -2
+ Misses 1046 1043 -3
+ Partials 166 165 -1 ☔ View full report in Codecov by Sentry. |
Previously, an add operation would simply append the data object to the end of the data section. If one or more object(s) had previously been deleted from the image, this could result in wasted space. Now, we trim the data section based on in-use objects before adding the new object. Update tests to reflect this new behaviour.
Improve compaction via OptDeleteCompact. Do not fail when compaction is requested on a data object that is not at the end of the data section. When compaction is requested, always calculate the end of the data section based on the in-use descriptors.
That's a result of this line: Those two test cases delete the last object in the SIF without supplying the compact option, and then add a new object. Previously, the code would append after the end of the data section (which still included the deleted object.) The new code calculates where the end of the valid data actually is, and appends there. |
Thanks... apologies I missed that! |

Improve the behaviour of image compaction when adding/deleting data objects.
Improve compaction when
OptDeleteCompactis supplied toDeleteObject. Do not fail when compaction is requested on a data object that is not at the end of the data section. When compaction is requested, always calculate the end of the data section based on the in-use descriptors.Previously,
AddObjectwould simply append the data object to the end of the data section. If one or more object(s) had previously been deleted from the image, this could result in wasted space. Now, we trim the data section based on in-use objects before adding the new object.Add/update tests to reflect new behaviour.
Closes #193