diff options
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 ~= |
