aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/out_src_pod.org
diff options
context:
space:
mode:
Diffstat (limited to 'org/out_src_pod.org')
-rw-r--r--org/out_src_pod.org50
1 files changed, 35 insertions, 15 deletions
diff --git a/org/out_src_pod.org b/org/out_src_pod.org
index 678d5ac..793fa49 100644
--- a/org/out_src_pod.org
+++ b/org/out_src_pod.org
@@ -66,6 +66,7 @@ template spinePod() {
}
}
<<source_pod_mkdirs>>
+ <<struct_data_digest_and_length_return>>
<<source_pod_archive_prepare_for_zip_and_get_digests>>
<<source_pod_archive_zip>>
<<zip_archive>>
@@ -79,6 +80,7 @@ template spinePod() {
#+NAME: output_imports
#+BEGIN_SRC d
import std.digest.sha;
+// import std.digest : toHexString;
import std.file;
import std.outbuffer;
import std.zip;
@@ -105,6 +107,28 @@ static auto rgx_files = RgxFiles();
assert (doc_matters.src.filename.match(rgx_files.src_fn));
#+END_SRC
+** sha256
+
+#+NAME: struct_data_digest_and_length_return
+#+HEADER: :noweb yes
+#+BEGIN_SRC d
+// ↓ - 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
+#+END_SRC
+
** source pod archive, (prepare for zip) :copy:
#+NAME: source_pod_archive_prepare_for_zip_and_get_digests
@@ -138,9 +162,8 @@ auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) {
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);
@@ -177,9 +200,9 @@ auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) {
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);
@@ -278,9 +301,8 @@ auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) {
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;
@@ -339,9 +361,8 @@ auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) {
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)) {
@@ -367,9 +388,8 @@ auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) {
} 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(