Repository navigation
fix(pycvc): save() must create the volume file before writing - #110
Merged
Merged
Conversation
Volume::save() called the free-function writeVolumeFile(app, vol, filename) overload, which writes into an *already-existing* file (the chunk/offset write path) and does not create it. For a fresh path the format handler threw while trying to read the missing file, which writeVolumeFile re-wraps as unsupported_volume_file_type — misleadingly suggesting the .rawiv handler was unregistered. It is not: the handler map is fully populated across the shared-library boundary via app::registerDefaultHandlers(). Delegate save()/load() to cvc::volume::write()/read(), the canonical members that createVolumeFile() the target first and then fill it in. Drop the test's soft-skip that assumed the handler might be unregistered and assert the .rawiv round-trip unconditionally (register_rawiv_io is never conditionally compiled).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
pycvc.Volume.save('x.rawiv')failed withunsupported_volume_file_type, even though.rawivis the canonical CVC format. This blocked volume file I/O for external SDK consumers built on the new pycvc Volume binding.Root cause (not what it looked like)
The symptom suggested the
.rawivhandler was missing — the theory being that libcvc's format-handler TUs get stripped by the linker in a shared build. That is not what's happening. Handler registration was already refactored away from static initializers to explicitregister_*_io(app&)calls invoked byapp::registerDefaultHandlers(); becauseapp.cppreferences those symbols, the TUs are always linked intolibcvc.so. A tiny consumer linked against the sharedcvc::cvcconfirms the map is fully populated across the library boundary:The real bug is in the facade.
Volume::save()called the free-functionwriteVolumeFile(app, vol, filename)overload, which writes into an already-existing file (the chunk/offset write path) and does not create it. For a fresh path the.rawivhandler throws while trying to read the not-yet-existent file, andwriteVolumeFilere-wraps that asunsupported_volume_file_type— hence the misleading symptom. The failure is actually aread_error: No such file or directoryraised insidevolume_file_info::read, i.e. a registered handler ran.Fix
Delegate
save()/load()to the canonical memberscvc::volume::write()/read().write()doescreateVolumeFile()and thenwriteVolumeFile()— the same idiom the library uses internally. No change to libcvc itself is needed (no whole-archive /--no-as-needed/attribute((used))).Also drops the test's soft-skip that assumed the handler might be unregistered and asserts the
.rawivround-trip unconditionally (register_rawiv_iois never conditionally compiled).Verification
read_error: No such file, vector/write()path round-trips cleanly._pycvc.so;test_pycvc.pypasses end-to-end including the now-unconditional.rawivround-trip.v.save('field.rawiv')) now writes a valid 100-byte.rawiv(68-byte header + 8×4-byte floats) and loads back with correct dims/values.