clawhdf5: FileEditor reports filters it cannot run as Error::Unsupported
A dataset whose filter this build cannot encode (scale-offset, N-Bit, SZIP;
a plugin filter the build lacks) failed with Error::Format("unsupported
filter: 6"), although the editor documents every refused edit as
Error::Unsupported, and the Python bindings raised ValueError rather than
NotImplementedError. Every edit now maps FormatError::UnsupportedFilter to
Error::Unsupported; the file is left untouched as before.
Test: edit_interop unencodable_filters_are_unsupported — h5py scale-offset
datasets (integer with chunks, integer never written, float D-scale):
Error::Unsupported naming the filter, and the file byte for byte unchanged.
Fails on the previous editor (Format(UnsupportedFilter(6))).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -622,7 +622,7 @@ impl FileEditor {
|
||||
check_editable(&f)?;
|
||||
let sb = f.superblock().clone();
|
||||
let mut img = Image::new(f.as_bytes(), sb.offset_size, sb.length_size);
|
||||
let r = op(&f, &mut img)?;
|
||||
let r = op(&f, &mut img).map_err(unsupported_filter)?;
|
||||
if img.is_dirty() {
|
||||
if img.eoa() != img.old_eoa() {
|
||||
set_superblock_eof(&mut img, &sb)?;
|
||||
@@ -840,6 +840,20 @@ impl FileEditor {
|
||||
}
|
||||
}
|
||||
|
||||
/// A filter this build cannot run (scale-offset, N-Bit and SZIP have no
|
||||
/// encoder; a plugin filter may be missing) is something the editor does not
|
||||
/// support, not a malformed file.
|
||||
fn unsupported_filter(e: Error) -> Error {
|
||||
match e {
|
||||
Error::Format(clawhdf5_format::error::FormatError::UnsupportedFilter(id)) => {
|
||||
Error::Unsupported(format!(
|
||||
"datasets with filter {id}, which this build cannot run"
|
||||
))
|
||||
}
|
||||
e => e,
|
||||
}
|
||||
}
|
||||
|
||||
/// libhdf5's checks before it opens a file for writing, and what this
|
||||
/// editor cannot keep consistent.
|
||||
fn check_editable(f: &File) -> Result<(), Error> {
|
||||
|
||||
Reference in New Issue
Block a user