From c16ada7749d842fa868b7b8b25a1ff17ffdf7b40 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 8 Sep 2026 16:09:44 -0400 Subject: output: the abstraction artefacts live with the pod pod/ holds all document source representations: pod// source tree pod//media/abstraction/.ssp abstraction, as text pod/.zip tree, zipped, .ssp included pod/.digests.txt sha256s of what is in them pod/.ocda.db abstraction, as sqlite db /abstraction/ is gone. pod//media/abstraction/.ssp preferred as having the images (found within the pod tree) which .ssp needs to reproduce a document but does not carry on its own. The .ocda.db sits carries the images as well and (like the pod.zip) can be used to reproduce a document directly. digests.txt now covers the database as well as the zip, the source and the .ssp; (as does the metadata html page). Two ordering issues addressed: - the pod builder clean-slates pod// before regenerating it, and the .ssp is now written before that runs. The clean slate now leaves media/abstraction/ alone, and the .ssp writer clears that directory itself on the first language of a run, so a .ssp for a language the document no longer is removed and cannot be bundled. - for a multi-language document the .ssp files accumulate one language at a time and are bundled on the last, which is why the directory cannot simply be emptied by whichever (language) gets there first. (assisted by Claude-Code) --- src/sisudoc/outputs/io_out/source_pod.d | 68 +++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 15 deletions(-) (limited to 'src/sisudoc/outputs/io_out/source_pod.d') diff --git a/src/sisudoc/outputs/io_out/source_pod.d b/src/sisudoc/outputs/io_out/source_pod.d index b32abcd..0ed26db 100644 --- a/src/sisudoc/outputs/io_out/source_pod.d +++ b/src/sisudoc/outputs/io_out/source_pod.d @@ -73,13 +73,35 @@ template spinePod() { assert (doc_matters.src.filename.match(rgx_files.src_fn)); if (doc_matters.opt.action.source_or_pod) { try { - /+ ↓ clean slate: remove per-document pod directory before regeneration, - but only on the first language of a multi-language document, - so that subsequent languages' files are not wiped +/ + /+ ↓ clean slate: remove the per-document pod directory before + regeneration, but only on the first language of a multi-language + document, so that subsequent languages' files are not wiped. + . + media/abstraction/ is left alone: the .ssp files there are written + by the abstraction stage, which runs before this, and for a + multi-language document they accumulate one language at a time. + That directory clears itself, in the .ssp writer, on the first + language of a run. + +/ if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[0]) { string doc_pod_dir = pths_pod.base_filesystem_(doc_matters.src.filename); + string keep_dir + = pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod.to!string; if (exists(doc_pod_dir) && doc_pod_dir.isDir) { - doc_pod_dir.rmdirRecurse; + foreach (string _e; dirEntries(doc_pod_dir, SpanMode.shallow)) { + if (_e.isDir) { + if (keep_dir.startsWith(_e)) { // media/, which holds abstraction/ + foreach (string _m; dirEntries(_e, SpanMode.shallow)) { + if (_m == keep_dir) { continue; } + if (_m.isDir) { _m.rmdirRecurse; } else { _m.remove; } + } + } else { + _e.rmdirRecurse; + } + } else { + _e.remove; + } + } } } { @@ -208,24 +230,24 @@ template spinePod() { } } } - } { // bundle abstraction .ssp file (only for --pod2) + } { // the abstraction .ssp, written in place by --show-abstraction (only for --pod2) if (doc_matters.opt.action.pod2) { - if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { // wait until all language versions of .ssp generated - import sisudoc.outputs.io_out.paths_output; - /+ doc_uid_out for any language follows the same pattern, differing + if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { // wait until all language versions of .ssp written + /+ the .ssp is written straight into pod//media/abstraction/, + so there is nothing to copy here: it is digested and added to + the zip where it stands. + doc_uid_out for any language follows the same pattern, differing only in the trailing ".{lng}". Strip the current language to - reuse the base across all languages. +/ + reuse the base across all languages. + +/ string _doc_uid_base = doc_matters.src.doc_uid_out[0 .. $ - doc_matters.src.lng.length]; foreach (_lang; doc_matters.pod.manifest_list_of_languages) { // do for all language versions - auto out_pth_lng = spineOutPaths!()(doc_matters.output_path, _lang); - string abstraction_dir = ((out_pth_lng.output_base.chainPath("abstraction")).asNormalizedPath).array; string ssp_filename = _doc_uid_base ~ _lang ~ ".ssp"; - string fn_src_in = ((abstraction_dir.chainPath(ssp_filename)).asNormalizedPath).array.to!string; auto fn_src_out_pod_zip_base = pths_pod.abstraction_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ ssp_filename; - auto fn_src_out_filesystem + auto fn_src_in = pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod.to!string ~ "/" ~ ssp_filename; if (exists(fn_src_in)) { @@ -235,13 +257,26 @@ template spinePod() { _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); } else { if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) { writeln("WARNING (io) src out NOT found (abstraction): ", fn_src_in); } } + /+ ↓ the .ocda.db sits beside the pod rather than inside it: it + carries the images itself, and putting it in the zip would + store them twice. digested here so that digests.txt covers + every artefact the pod directory holds for this document + +/ + { + string db_filename = _doc_uid_base ~ _lang ~ ".ocda.db"; + string fn_db = pths_pod.pod_dir_() ~ "/" ~ db_filename; + if (exists(fn_db)) { + ST_file_stat file_ = getFileStat(fn_db); + _digests[_lang]["ocda_db"] ~= file_.sha256hash.toHexString + ~ "::" ~ file_.fileSize.to!string ~ " - " ~ db_filename ~ "\n"; + } + } } } } @@ -539,7 +574,10 @@ template spinePod() { f.writeln(_digests[_lang]["ssi"]); } if (("ssp" in _digests[_lang]) && (_digests[_lang]["ssp"].length > 0)) { - f.writeln(_digests[_lang]["ssp"]); + f.writeln(_digests[_lang]["ssp"].strip); + } + if (("ocda_db" in _digests[_lang]) && (_digests[_lang]["ocda_db"].length > 0)) { + f.writeln(_digests[_lang]["ocda_db"].strip); } } } -- cgit v1.2.3