diff options
Diffstat (limited to 'org/ocda_functions.org')
| -rw-r--r-- | org/ocda_functions.org | 24 |
1 files changed, 18 insertions, 6 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 ~= |
