diff options
Diffstat (limited to 'src/sisudoc')
| -rw-r--r-- | src/sisudoc/ocda/abstraction/ssp.d | 5 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src_functions.d | 24 |
2 files changed, 22 insertions, 7 deletions
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 ~= |
