fix: filemeta version handling and delete operations #879
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.
Fix: FileMeta Version Handling and Delete Operations
Summary
This PR fixes critical issues in file metadata version handling, specifically addressing:
Type of Change
Related Issues
#844
Problem
The previous implementation had several version-related issues:
reverse()which didn't properly handle all version attributesUuid::max()instead ofUuid::nil()as default version IDChanges
1. Fixed Version Sorting Logic (
filemeta.rs)reverse()with comprehensive multi-field sortingmod_time,version_type,version_id, andflagssort_versions()andsort_versions_by_modtime()methods2. Fixed Delete Version with Nil UUID (
filemeta.rs)delete_version()method3. Fixed Version ID Serialization (
filemeta.rs)FileMetaVersionHeader::unmarshal()Some(Uuid), even for nil UUIDsinto_fileinfo()to preserve nil UUIDs instead of filtering them out4. Fixed Add Version with Nil UUID (
filemeta.rs)add_version()when version_id is None5. Fixed Directory Object Version ID (
ecfs.rs,options.rs)Uuid::max()toUuid::nil()del_opts(),get_opts(), andput_opts()functions6. Fixed Version ID Validation (
options.rs)7. Fixed Version Sorting in SetDisks (
set_disk.rs)reverse()after sorting versions8. Code Quality Improvements
Vec<FileInfo>to&[FileInfo]indelete_versions_internal()for better performance{err}instead of{}, err)Checklist
make pre-commitImpact
the version number generated for empty directory objects has been changed from uuid::max to uuid::nil. If there are previously created empty directories, they must be manually deleted from the data directory
here is a shell command to help delete existing empty directories:
Additional Notes
Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.