aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/outputs
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-07-30 23:24:06 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-07-31 14:48:09 -0400
commit569a22bdb0841f360af97683ded5006329a14b28 (patch)
tree5d8969d9c269792468219af492d068dfcb7ea720 /src/sisudoc/outputs
parentdigest (sha256) for document root heading (title) (diff)
digests (sha256) a revisit
Diffstat (limited to 'src/sisudoc/outputs')
-rw-r--r--src/sisudoc/outputs/io_out/source_pod.d42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/sisudoc/outputs/io_out/source_pod.d b/src/sisudoc/outputs/io_out/source_pod.d
index f6c73d6..b32abcd 100644
--- a/src/sisudoc/outputs/io_out/source_pod.d
+++ b/src/sisudoc/outputs/io_out/source_pod.d
@@ -51,6 +51,7 @@ module sisudoc.outputs.io_out.source_pod;
@system: // is not @safe: use: @system: or @trusted:
template spinePod() {
import std.digest.sha;
+ // import std.digest : toHexString;
import std.file;
import std.outbuffer;
import std.zip;
@@ -148,6 +149,21 @@ template spinePod() {
));
}
}
+ // ↓ - object digest & length
+ struct ST_file_stat {
+ ubyte[32] sha256hash;
+ ulong fileSize;
+ }
+ ST_file_stat getFileStat(F)(F filepath) @trusted {
+ auto file = File(filepath, "r");
+ ubyte[32] file_sha256 = digest!SHA256(file.byChunk(4096 * 1024));
+ ulong fileSize = file.size;
+ ST_file_stat _file;
+ _file.sha256hash = file_sha256;
+ _file.fileSize = fileSize;
+ return _file;
+ }
+ // ↑ - object digest & length
auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) {
auto pth_dr_doc_src = doc_matters.src_path_info;
if (doc_matters.opt.action.vox_gt_3) { // correct
@@ -177,9 +193,8 @@ template spinePod() {
if (exists(fn_src_in)) {
debug(io) { writeln("(io debug) src out found: ", fn_src_in); }
{ // take DIGEST write to pod file digests.txt
- auto data = (cast(byte[]) (fn_src_in).read);
- _digests["shared"]["images"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ image ~ "\n";
- // writeln(data.sha256Of.toHexString, "::", data.length, " - ", image);
+ ST_file_stat file_ = getFileStat(fn_src_in);
+ _digests["shared"]["images"] ~= file_.sha256hash.toHexString ~ "::" ~ file_.fileSize.to!string ~ " - " ~ image ~ "\n";
}
if (doc_matters.opt.action.source_or_pod) {
fn_src_in.copy(fn_src_out_filesystem);
@@ -216,9 +231,9 @@ template spinePod() {
if (exists(fn_src_in)) {
debug(io) { writeln("(io debug) src out found: ", fn_src_in); }
{ // take DIGEST write to pod file digests.txt
- auto data = (cast(byte[]) (fn_src_in).read);
- _digests[_lang]["ssp"] ~= data.sha256Of.toHexString
- ~ "::" ~ data.length.to!string ~ " - " ~ ssp_filename ~ "\n";
+ ST_file_stat file_ = getFileStat(fn_src_in);
+ _digests[_lang]["ssp"] ~= file_.sha256hash.toHexString
+ ~ "::" ~ file_.fileSize.to!string ~ " - " ~ ssp_filename ~ "\n";
}
fn_src_in.copy(fn_src_out_filesystem);
zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip);
@@ -317,9 +332,8 @@ template spinePod() {
if (exists(_pth_file_sstm)) { // what of language?
debug(io) { writeln("(io debug) src in found: ", _pth_file_sstm); }
{ // take DIGEST write to pod file digests.txt
- auto data = (cast(byte[]) (_pth_file_sstm).read);
- _digests[_lang]["sstm"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ doc_matters.src.filename ~ " - [" ~ _lang ~ "]";
- // writeln(data.sha256Of.toHexString, "::", data.length, " - ", doc_matters.src.filename);
+ ST_file_stat file_ = getFileStat(_pth_file_sstm);
+ _digests[_lang]["sstm"] ~= file_.sha256hash.toHexString ~ "::" ~ file_.fileSize.to!string ~ " - " ~ doc_matters.src.filename ~ " - [" ~ _lang ~ "]";
}
filelist_src_out_pod_arr ~= fn_src_out_pod_zip_base;
filelist_src_zpod_arr ~= fn_src_out_inside_pod;
@@ -378,9 +392,8 @@ template spinePod() {
foreach (_lang; doc_matters.pod.manifest_list_of_languages) {
string _pth_mkup_src_in = _path_to_pod ~ _podname ~ "/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename;
{ // take DIGEST write to pod file digests.txt
- auto data = (cast(byte[]) (_pth_mkup_src_in).read);
- _digests[_language]["ssi"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ _filename ~ " - [" ~ _lang ~ "]" ~ "\n";
- // writeln(data.sha256Of.toHexString, "::", data.length, " - ", _filename, " - [", _lang, "]");
+ ST_file_stat file_ = getFileStat(_pth_mkup_src_in);
+ _digests[_language]["ssi"] ~= file_.sha256hash.toHexString ~ "::" ~ file_.fileSize.to!string ~ " - " ~ _filename ~ " - [" ~ _lang ~ "]" ~ "\n";
}
string _pth_mkup_src_out = "pod/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename;
if (exists(_pth_mkup_src_in)) {
@@ -406,9 +419,8 @@ template spinePod() {
} else {
auto fn_src_in = insert_file;
{ // take DIGEST write to pod file digests.txt // FIX likely bug insert_file includes path, not what you wish to write
- auto data = (cast(byte[]) (fn_src_in).read);
- _digests["en"]["ssi"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ insert_file ~ "\n";
- // writeln(data.sha256Of.toHexString, "::", data.length, " - ", insert_file);
+ ST_file_stat file_ = getFileStat(fn_src_in);
+ _digests["en"]["ssi"] ~= file_.sha256hash.toHexString ~ "::" ~ file_.fileSize.to!string ~ " - " ~ insert_file ~ "\n";
}
auto fn_src_out_pod_zip_base
= pths_pod.fn_doc_insert(