diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-26 22:41:06 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-28 10:01:18 -0400 |
| commit | 8e7a8996944f80ca7e05d743b33deb1ac233f74f (patch) | |
| tree | 0481181ac87eedd22395e94ac25d0e3e0821f533 /src/sisudoc/ocda/meta/metadoc_from_src_functions.d | |
| parent | .ssp: image as repeatable self-describing property (diff) | |
.ssp digests: report missing or unreadable image
image digest: record missing or unreadable image, do not abort
safeComputeHashAndSize() open image with guard, so a document
naming an image absent from media/image/ throws
ErrnoException out of the abstraction stage.
as with _image_dimensions() (which warns and continues where issue
with image) warn to stdout and record the fact in the abstraction:
.image: ffa.png missing:true
the abstraction would now state that the object embeds an image it
could not read, rather than the .ssp resemble one produced from a
complete pod. The sha256 summary line marks the same case
MISSING OR UNREADABLE.
(assisted by Claude-Code)
Diffstat (limited to 'src/sisudoc/ocda/meta/metadoc_from_src_functions.d')
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src_functions.d | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d index 791c002..6e4aec3 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d @@ -3191,13 +3191,23 @@ template docAbstractionFunctions() { ) { ST_file_name_hash_size_ safeComputeHashAndSize(N,P)(N filename, P file_path) @trusted { auto file_with_path = file_path ~ filename; - auto file_read = File(file_with_path, "r"); - ubyte[32] file_sha256 = digest!SHA256(file_read.byChunk(4096 * 1024)); - ulong fileSize = file_read.size; ST_file_name_hash_size_ _file_info; - _file_info.fileHash_sha256 = file_sha256; - _file_info.fileSize = fileSize; _file_info.fileName = filename; + /+ ↓ a referenced image that is absent or unreadable is recorded as + such rather than aborting the abstraction (compare the WARNING + issued by _image_dimensions for the same situation) + +/ + try { + auto file_read = File(file_with_path, "r"); + ubyte[32] file_sha256 = digest!SHA256(file_read.byChunk(4096 * 1024)); + ulong fileSize = file_read.size; + _file_info.fileHash_sha256 = file_sha256; + _file_info.fileSize = fileSize; + } catch (Exception ex) { + _file_info.fileMissing = true; + writeln("WARNING, image not found or unreadable: ", filename, + "\n ", file_with_path); + } return _file_info; } obj.metainfo.sha256.text = obj.text.sha256Of; @@ -3224,7 +3234,9 @@ template docAbstractionFunctions() { char[] image_summary; if (obj.metainfo.sha256.images.length > 0) { foreach (i; obj.metainfo.sha256.images) { - image_summary ~= "\n - " ~ i.fileHash_sha256.toHexString ~ "::" ~ i.fileSize.to!string ~ " - " ~ i.fileName; + image_summary ~= (i.fileMissing) + ? "\n - " ~ "MISSING OR UNREADABLE" ~ " - " ~ i.fileName + : "\n - " ~ i.fileHash_sha256.toHexString ~ "::" ~ i.fileSize.to!string ~ " - " ~ i.fileName; } } obj.metainfo.sha256.summary ~= |
