aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-08-26 22:41:06 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-08-28 10:01:18 -0400
commit8e7a8996944f80ca7e05d743b33deb1ac233f74f (patch)
tree0481181ac87eedd22395e94ac25d0e3e0821f533
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)
-rw-r--r--org/ocda_functions.org24
-rw-r--r--org/ocda_obj_setter.org1
-rw-r--r--org/out_src_abstraction_ocda_ssp.org5
-rw-r--r--src/sisudoc/ocda/abstraction/ssp.d5
-rw-r--r--src/sisudoc/ocda/meta/metadoc_from_src_functions.d24
5 files changed, 45 insertions, 14 deletions
diff --git a/org/ocda_functions.org b/org/ocda_functions.org
index 37a4f6f..4745bc5 100644
--- a/org/ocda_functions.org
+++ b/org/ocda_functions.org
@@ -3431,13 +3431,23 @@ SHA_256_Hashes_ obj_digest(M)(
) {
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;
@@ -3464,7 +3474,9 @@ SHA_256_Hashes_ obj_digest(M)(
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 ~=
diff --git a/org/ocda_obj_setter.org b/org/ocda_obj_setter.org
index f419954..8e7a67c 100644
--- a/org/ocda_obj_setter.org
+++ b/org/ocda_obj_setter.org
@@ -53,6 +53,7 @@ struct ST_file_name_hash_size_ {
string fileName;
ubyte[32] fileHash_sha256;
ulong fileSize;
+ bool fileMissing = false; // file not found or unreadable, fileHash_sha256 & fileSize unset
}
struct SHA_256_Hashes_ {
char[] summary;
diff --git a/org/out_src_abstraction_ocda_ssp.org b/org/out_src_abstraction_ocda_ssp.org
index 2d8b128..d2bb8a4 100644
--- a/org/out_src_abstraction_ocda_ssp.org
+++ b/org/out_src_abstraction_ocda_ssp.org
@@ -275,7 +275,10 @@ template spineAbstractionTxt() {
+/
if (obj.metainfo.sha256.images.length > 0) {
foreach (i; obj.metainfo.sha256.images) {
- output ~= ".image: " ~ i.fileName
+ output ~= (i.fileMissing)
+ ? ".image: " ~ i.fileName
+ ~ " missing:true"
+ : ".image: " ~ i.fileName
~ " sha256:" ~ i.fileHash_sha256.toHexString.to!string
~ " bytes:" ~ i.fileSize.to!string;
}
diff --git a/src/sisudoc/ocda/abstraction/ssp.d b/src/sisudoc/ocda/abstraction/ssp.d
index 95f7fda..ea76d71 100644
--- a/src/sisudoc/ocda/abstraction/ssp.d
+++ b/src/sisudoc/ocda/abstraction/ssp.d
@@ -293,7 +293,10 @@ template spineAbstractionTxt() {
+/
if (obj.metainfo.sha256.images.length > 0) {
foreach (i; obj.metainfo.sha256.images) {
- output ~= ".image: " ~ i.fileName
+ output ~= (i.fileMissing)
+ ? ".image: " ~ i.fileName
+ ~ " missing:true"
+ : ".image: " ~ i.fileName
~ " sha256:" ~ i.fileHash_sha256.toHexString.to!string
~ " bytes:" ~ i.fileSize.to!string;
}
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 ~=